|
-
Nov 16th, 2007, 12:47 PM
#1
Thread Starter
Hyperactive Member
[RESOLVED] [2005] Refreshing DataGridView
How can i refresh the DGV to clear all values in it first and then update itself from the database containing current values?
-
Nov 16th, 2007, 01:08 PM
#2
Re: [2005] Refreshing DataGridView
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.
-
Nov 16th, 2007, 08:12 PM
#3
Re: [2005] Refreshing DataGridView
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.
-
Nov 17th, 2007, 04:31 AM
#4
Thread Starter
Hyperactive Member
Re: [2005] Refreshing DataGridView
How can i Clear the datatable (DataGridView) ?
-
Nov 17th, 2007, 05:29 AM
#5
Re: [2005] Refreshing 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.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|