RE: Show empty GridView as empty grid by stcheng
stcheng
Tue Oct 17 03:16:33 CDT 2006
Hello Dave,
If you want to display Row (no matter empty or not), we have to bind
Gridview with a datasource. Actually, if the expected datasource's schema
is not very complex, you can simply create a empty DataTable and bind it to
GridView. e.g:
==========================
protected void Page_Load(object sender, EventArgs e)
{
DataTable dt = new DataTable();
dt.Columns.Add("name");
dt.Columns.Add("description");
dt.Rows.Add(new object[] {"","" });
GridView2.DataSource = dt;
GridView2.DataBind();
}
===========================
Otherwise, we can only use the EmptyDataTemplate to provide the UI to
display when there is no data.
===============
<EmptyDataTemplate>
..............
</EmptyDataTemplate>
</asp:GridView>
===============
Sincerely,
Steven Cheng
Microsoft MSDN Online Support Lead
This posting is provided "AS IS" with no warranties, and confers no rights.