绑定GRIDVIEW时无数据显示表头方法
2008-07-19 15:42
519 查看
/// <summary>
/// 如果没有查询到任何信息则显示表头
/// </summary>
/// <param name="gv"></param>
/// <param name="ds"></param>
public static void BindNullDataSet(GridView gv, DataSet ds)
{
if (ds.Tables[0].Rows.Count == 0)
{
ds.Tables[0].Rows.Add(ds.Tables[0].NewRow());
gv.DataSource = ds;
gv.DataBind();
int columnCount = ds.Tables[0].Columns.Count;
gv.Rows[0].Cells.Clear();
gv.Rows[0].Cells.Add(new TableCell());
gv.Rows[0].Cells[0].ColumnSpan = columnCount;
gv.Rows[0].Cells[0].Text = "---没有记录---";
gv.Rows[0].Cells[0].Style.Add("text-align", "center");
}
else
{
gv.DataSource = ds;
gv.DataBind();
}
/// 如果没有查询到任何信息则显示表头
/// </summary>
/// <param name="gv"></param>
/// <param name="ds"></param>
public static void BindNullDataSet(GridView gv, DataSet ds)
{
if (ds.Tables[0].Rows.Count == 0)
{
ds.Tables[0].Rows.Add(ds.Tables[0].NewRow());
gv.DataSource = ds;
gv.DataBind();
int columnCount = ds.Tables[0].Columns.Count;
gv.Rows[0].Cells.Clear();
gv.Rows[0].Cells.Add(new TableCell());
gv.Rows[0].Cells[0].ColumnSpan = columnCount;
gv.Rows[0].Cells[0].Text = "---没有记录---";
gv.Rows[0].Cells[0].Style.Add("text-align", "center");
}
else
{
gv.DataSource = ds;
gv.DataBind();
}
相关文章推荐
- gridview 绑定数据为空时,表头部分内容显示的解决方法
- GridView绑定数据源,无记录时表头也显示的一种解决方法
- GridView绑定数据源,无记录时表头也显示的一种解决方法
- gridview无数据行时显示表头的方法
- GridView绑定数据源,无记录时表头也显示的一种解决方法
- datagrid绑定list没有数据 表头不显示的解决方法
- GridView绑定数据源,无记录时表头也显示的一种解决方法
- GridView数据绑定时数据源为空时显示表头和"没有记录"
- 前台用Gridview绑定数据时时间只显示 年月日 的方法
- GridView控件无数据也显示表头方法二[转]
- Gridview所绑定的数据为空时显示表头
- GridView绑定数据源,无记录时表头也显示的一种解决方法
- GridView绑定数据源,无记录时表头也显示的一种解决方法
- GridView绑定数据源,无记录时表头也显示的一种解决方法
- GridView绑定数据源,无记录时表头也显示的一种解决方法
- datagrid绑定list没有数据 表头不显示的解决方法
- GridView,空数据时显示表头最简单的方法!
- gridview无数据行时显示表头的方法
- asp.net GridView 后台绑定数据无数据显示表头及没有数据一行
- 当Gridview没有数据 显示表头