Zo Has Zo Has - 3 months ago 13
ASP.NET (C#) Question

Show gridview footer on empty grid?

just wanted to know what is the best and easiest way to show a gridview footer for data entry even when the gridview is empty ?

Answer

Set your datasource to the type of object you're binding to the GridView with one object filled with empty values, then hide that DataRow.

EDIT: Since you're using a datatable...

DataTable dt = new DataTable();

// Define all of the columns you are binding in your GridView
dt.Columns.Add("AColumnName");
...
...

DataRow dr = dt.NewRow();
dt.Rows.Add(dr);

myGridView.DataSource = dt;
myGridView.DataBind();