To make your data appear on a form, you bind a Microsoft
Windows Forms
DataGrid control to a
DataTable object that is included in a
DataSet object.
After your data has appeared in the
DataGrid control, you use the
Tables.Clear method to remove the
DataTable object from the
Tables collection of the bound
DataSet object. However, although the bound
DataSet object no longer contains any data, your original data continues
to appear in the
DataGrid control.
In a Microsoft Windows-based application, the
CurrencyManager object manages a list of
Binding objects. When you use a
DataSet object together with a
DataTable object for your data source, and you bind a
DataGrid control to the
DataSet object and the
DataTable object, the
CurrencyManager object manages this data source.
However, if you remove
the
DataTable object from the
DataSet object, the related the
CurrencyManager object that corresponds to the
DataSet object is not updated. Therefore, the
DataGrid control does not have this new information and the original data
continues to appear in the
DataGrid control.
To work around this problem, use the
DataSource property instead of the
SetDataBinding method to set the data source of the
DataGrid control, as in the following sample code.
Microsoft Visual Basic .NET codeDataGrid1.DataSource = myDataSet.Tables("TableName")Microsoft Visual C# .NET codedataGrid1.DataSource = myDataSet.Tables["TableName"];
Microsoft has confirmed that this is a bug in the Microsoft
products that are listed in the "Applies to" section of this
article.
For additional
information, click the following article number to view the article in the
Microsoft Knowledge Base: