开发者

How to clear an ASP.NET datagrid?

how do i clear the contents of a data grid that's bound to an list of generic objects?

private void BindGrid(ReportWizardCriteria criteria)
{

    gvCriteria.DataSour开发者_StackOverflow社区ce = criteria.CriteriaList;
    gvCriteria.DataBind();
}


gvCriteria.DataSource = null;
gvCriteria.DataBind();

Or you can bind it to an empty collection as well, similar to this

gvCriteria.DataSource = new List<MyObject>();
gvCriteria.DataBind();

For some people the second one is a bit "easier" to understand


You can set the .DataSource property to null. That ought to do it.

gvCriteria.DataSource = null;
gvCriteria.DataBind();


try,

gvCriteria.Items.Clear();

or,

gvCriteria.DataSource = null;

gvCriteria.DataBind();

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜