Possible Duplicate:
How can I clear rows in DataGridView with C#?
I am using gridview to show details of some of my data. The flow is like this: when a dropdown value is changed, the data in the gridview is bound according to the selected value. Now when there is no data corresponding to that value, I need to clear the gridview. For this I use:
gridview1.Rows.Clear()
But when I compile my code, an error is generated:
System.Web.UI.WebControls.GridViewRowCollection' does not contain a definition for
'Clear' and no extension method 'Clear' accepting a first argument of type
'System.Web.UI.WebControls.GridViewRowCollection' could be found (are you missing
a using directive or an assembly reference?)
I have also given the reference:
using System.Web.UI.WebControls;
Now how should I clear the gridview?
Thanks in advance.
You can bind the
GridViewwithnull, or with a newDataSource.