0
votes

I used the following code to add data into DataGridView control

query = "SELECT * FROM primary_student_table WHERE admityear=" & admityear & " AND batch= " & batch & ""
        da = New SqlDataAdapter(query, con)
        da.Fill(ds, "primary_student_table")
        DataGridView1.DataSource = ds.Tables("primary_student_table")

I need to display records from another table later in the same control so I need to clear the table. How can I do this in VB.NET?

I am using SQL Server

3
So why don't you fill the same DataSet with the other DataTable and use that as DataSource for the DataGridView? - Tim Schmelter
This piece of code gets executed once or twice so that I want to reset the content prior loading it - Random User

3 Answers

0
votes

Set the Datasource to Nothing then rebind it to the new table.

0
votes

Im not an expert but I think you want this.

DataGridView1.Rows.Clear()

Hope it helped

0
votes

If someone still need help about clearing datagridview :

DataGridView1.Rows.Clear().

DataGridView1.Columns.Clear()

I hope it helped.