Home
Search
 
What's New
Index
Books
Links
Q & A
Newsletter
Banners
 
Feedback
Tip Jar
 
C# Helper...
 
XML RSS Feed
Follow VBHelper on Twitter
 
 
 
MSDN Visual Basic Community
 
 
 
 
TitleReset a DataGrid control when the data to which it is bound changes in VB .NET
KeywordsDataGrid, database, VB.NET
CategoriesControls, 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.
 
 
Copyright © 1997-2010 Rocky Mountain Computer Consulting, Inc.   All rights reserved.
  Updated