Digital Colony!

Clear GridView Control in ASP.NET

Clearing a populated GridView control can be done in just 3 lines of code. Create an empty DataTable and then bind it to the Gridview.
DataTable dt = new DataTable();
GridView1.DataSource = dt;
GridView1.DataBind();

Labels:

AddThis Social Bookmark Button

2 Comments:

Anonymous K5 said...

Also make sure if your setting DataKeyNames, while resetting are set to null.

6/12/2008 9:50 AM

Anonymous Anonymous said...

Or in 2 lines:
GridView1.DataSource = Nothing; GridView1.DataBind();

7/03/2008 4:27 AM

 

Post a Comment

 

Digital Colony Copyright © 1999-2008 XHTML   508
This site uses Blogger, which is not 100% XHTML compliant.
Try...Catch Disclaimer: For brevity many examples do not include error handling. That is your responsibility.