How can i refresh the DGV to clear all values in it first and then update itself from the database containing current values?
Printable View
How can i refresh the DGV to clear all values in it first and then update itself from the database containing current values?
Use databinding. To clear, you set the DataSource property of your DGV to Nothing. To display new data, you query your database for whatever data you need then set the datasource property to the of the DGV to that data.
You shouldn't be setting the DataSource of the grid to Nothing. If the grid is bound to a DataTable then leave it bound to that DataTable. You simply Fill that DataTable using a DataAdapter or TableAdapter and the bound grid will display the new contents. If you need to Clear the DataTable first then do so.
How can i Clear the datatable (DataGridView) ?
When you read the MSDN documentation for the DataTable class you must have missed the Clear method. You'll have to look more carefully when reading the MSDN documentation in the future, won't you?
Note that if you're using a TableAdapter to Fill the DataTable then it will implicitly call the table's Clear method for you, assuming that its ClearBeforeFill property (or a similar name) is set to True, which I think it is by default.