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();
This entry was posted in ASP.NET and tagged , . Bookmark the permalink.

One Response to Clear GridView Control in ASP.NET

  1. shahnila says:

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