How to make the datagrid with no data?
I have a page with two buttons: one is Load开发者_StackOverflow社区 Data
and the other Clear Data
.
I am using DataSet and have used ds.Tables.Clear() in that click code.
If the user clicks Clear Data
will the data in the datagrid disappear or not?
For showing grid with no rows, check GridView.EmptyDataTemplate Property
or
You can create an empty row and add to your datagrid like this -
if(datatable.Rows.Count == 0)
{
datatable.Rows.Add(datatable.NewRow);
}
datagrid.DataSource = datatable;
datagrid.DataBind();
According to your comment, the answer is No.
精彩评论