BUG: The original data appears in the DataGrid control although you have removed the data from the DataSet object (812919)
The information in this article applies to:
- Microsoft ADO.Net 2.0
- Microsoft ADO.NET (included with the Windows .NET Framework 1.1)
- Microsoft ADO.NET (included with the .NET Framework) 1.0
- Microsoft Visual Basic 2005
- Microsoft Visual Basic .NET (2003)
- Microsoft Visual Basic .NET (2002)
- Microsoft Visual C# 2005, Express Edition
- Microsoft Visual C# .NET (2003)
- Microsoft Visual C# .NET (2002)
SYMPTOMSTo 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.CAUSEIn 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.WORKAROUNDTo 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"]; STATUSMicrosoft has confirmed that this is a bug in the Microsoft
products that are listed in the "Applies to" section of this
article.REFERENCES For additional
information, click the following article number to view the article in the
Microsoft Knowledge Base: 313482
INFO: Roadmap for Windows Forms data binding
Modification Type: | Minor | Last Reviewed: | 10/3/2006 |
---|
Keywords: | kbvs2002sp1sweep kbcode kbpending kbDataview kbDataBinding kbControl kbSystemData kbWindowsForms kbbug KB812919 kbAudDeveloper |
---|
|