Show gridview footer on empty grid?

后端 未结 6 2148

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 17:56

    You can create an "empty" row and make it invisible:

    if (list != null && list.Any())
            {
                gridView.DataSource = list;
                gridView.DataBind();
            }
            else
            {
                MyCustomClass item = new MyCustomClass(){Id = 0, Name = "(No Data Rows)", Active = false};
                List l = new List();
                l.Add(item);
                gridView.DataSource = l;
                gridView.DataBind();
                gridView.Rows[0].Visible = false;
            }
    

提交回复
热议问题