How to clear gridview

I want to clear gridview. I have 2 GridViews and there is a select button on it. when this button is selected, this element goes into the second grid view. Now the question is how to clean the second kind of grid. I am trying to clear a method, but a clear method was not found in my visual studio.

+3
source share
4 answers
dataGridView1.DataSource = null;

or

dataGridView1.Rows.Clear();
+11
source
gridview.DataSource = null;
//rebind to gridview
gridview.DataBind();
+8
source

dataGridView1.Columns.Clear (); // this clears the entire Gridview

0
source

Just add the following C # code to clear the GridView: -

gridView.Rows.Clear ();

-2
source

Source: https://habr.com/ru/post/1732648/


All Articles