Show gridview footer on empty grid?

后端 未结 6 2146

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 ?

6条回答
  •  無奈伤痛
    2020-12-06 18:02

    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();
    

提交回复
热议问题