Differences clear function of gridview
How can I clear data in a GridView? is appeared
GridView1.DataSource = null;
GridView1.DataBind();
I want to Know difference of
GridView1.Clear();
two function of GridView1.Clear() and GridView1.DataSource = null.I have no error which clear of syntax of GridView1.Clear().
Public Sub Clear()
Data.Dispose()
Data = New DataSet
开发者_JAVA技巧 MyBase.DataSource = Nothing
End Sub
I wrote new class of gridview Inherits System.Windows.Forms.DataGridView.Vb class called my clear function in its class.Sorry,gridview.Clear() is not have.
I don't see any Clear() method listed for GridView Methods.
If you want to clear the current rows in a GridView, the answer you linked to above is the way to do it:
'VB.NET
GridView1.DataSource = Nothing
GridView1.DataBind()
//C#
GridView1.DataSource = null;
GridView1.DataBind();
If the above isn't working for you, please update your question with the code and what error, if any, you're seeing.
If you want to delete the rows of a gridview you can use this: Gridview1.Rows.Clear();
精彩评论