GridView当中插入一条空记录,显示其它提示一下表头

来源:互联网 发布:it技术支持工程师 编辑:程序博客网 时间:2024/05/16 11:25
DataTable dt = GetTable();//把gettable()换成你自己的数据就可以了
if (GetTable().Rows.Count == 0)
{

dt.Rows.Add(dt.NewRow());
this.GridView1.DataSource = dt;
GridView1.DataBind();
int columnCount = GridView1.Rows[0].Cells.Count;
GridView1.Rows[0].Cells.Clear();
GridView1.Rows[0].Cells.Add(new TableCell());
GridView1.Rows[0].Cells[0].ColumnSpan = columnCount;
GridView1.Rows[0].Cells[0].Text = "无符合数据,请重新设定搜索条件.";
GridView1.Rows[0].Cells[0].ForeColor = System.Drawing.Color.Red;
}
原创粉丝点击