水珮风裳  
First seperating,Finally meeting.
有一种厌倦叫热情;有一种等待叫积极;有一种发呆叫思索;有一种逃离叫勇气.
/**//// <summary>
/// 当DataSet为空时也显示GridView的表头
/// </summary>
/// <param name="gridView">所要绑定的GridView</param>
/// <param name="ds">所要绑定的数据集</param>
/// <returns>void </returns>

public void BindNoRecords(GridView gridView, DataSet ds)
...{
     
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 = "没有数据";
          gridView.RowStyle.HorizontalAlign
= System.Web.UI.WebControls.HorizontalAlign.Center;
     }

}
  
posted on 2008-04-25 18:19  水冰月  阅读(609)  评论(0)    收藏  举报