GridView绑定数据源,无记录时表头也显示的一种解决方法

转:Show Header/Footer of Gridview with Empty Data Source public void BuildNoRecords(GridView gridView, DataSet ds)     {         try         {             if (ds.Tables(0).Rows.Count == 0)             {                 ds.Tables(0).Rows.Add(ds.Tables(0).NewRow());                 gridView.DataSource = ds; gridView.DataBind(); int columnCount = gridView.Rows(0).Cells.Count; gridView.Rows(0).Cells.Clear(); gridView.Rows(0).Cells.Add(new TableCell()); gridView.Rows(0).Cells(0).ColumnSpan = columnCount; gridView.Rows(0).Cells(0).Text = "No Records Found.";             }         }         catch (Exception ex) { }     }

posted on 2008-06-20 00:53  oldkingsir  阅读(579)  评论(0编辑  收藏  举报

导航