|
|
Title | Reset a DataGrid control when the data to which it is bound changes in VB .NET |
Keywords | DataGrid, database, VB.NET |
Categories | Controls, VB.NET, Database |
|
|
If the database's data has changed, you need to reload the DataGrid control to display the new data.
First, clear the DataSet to remove old data. If you don't do this, reloading the DataSet will merge changes made to the DataSet's data with the newly loaded data.
Next refill the DataSet. Then call the DataGrid control's ResetBindings method.
|
|
dsUsers.Clear() ' Remove the old data.
daUsers.Fill(dsUsers) ' Reload the data.
DataGrid1.ResetBindings() ' Redisplay the data.
|
|
For lots more information on database programming in VB .NET, see my book Visual Basic .NET Database Programming.
|
|
|
|
|
|