BUG: AddNew method of CurrencyManager fails with bound CheckBox (326440)
The information in this article applies to:
- Microsoft .NET Framework Class Libraries 1.1
- Microsoft .NET Framework Class Libraries 1.0
- Microsoft .NET Framework 2.0
- Microsoft Visual Basic 2005 Express Edition
- Microsoft Visual Basic .NET (2003)
- Microsoft Visual Basic .NET (2002)
This article was previously published under Q326440 SYMPTOMS When you call the AddNew method to add a new record to a DataTable object that the CurrencyManager object manages, the method silently fails and does not advance to
a new record. CAUSE This problem occurs under the following circumstances:
- The form contains a CheckBox control whose Checked property is bound to a DataColumn object. -and-
- The DefaultValue property of the DataColumn object is set to System.DBNull.
This problem may occur even if the column in the underlying
database has a default value of True or False. The Checked property of a CheckBox control can only accept boolean values ( True or False) and does not understand Null. Therefore, you cannot position CurrencyManager on a new row when the DefaultValue of the DataColumn is set to System.DBNull. RESOLUTION To resolve this problem, programmatically modify the DataColumn object in the DataTable, and then set its DefaultValue property to True or to False. NOTE: This does not modify the property in the underlying database.
This only applies to the instance of the DataTable class that the CurrencyManager is using. For example, to set the DefaultValue of the Discontinued column in the DataTable object, follow these steps:
- Follow steps 1 through 9 of the "Steps to Reproduce the
Behavior" section of this article.
- Add the following code at the end of the BindControls procedure:
If dt.Columns("Discontinued").DefaultValue Is System.DBNull.Value Then
dt.Columns("Discontinued").DefaultValue = False 'or True if it should be checked by default
End If
- On the Debug menu, click Start.
- Click the button. Notice that the controls are cleared when
the CurrencyManager advances to a new record.
STATUSMicrosoft has confirmed that this is a bug in the Microsoft products that are listed in the "Applies to" section.REFERENCES
For more information, click the following article number to view the article in the Microsoft Knowledge Base:
321504
BUG: A check box is not cleared when you call the AddNew method on a DataSet
Modification Type: | Major | Last Reviewed: | 2/11/2006 |
---|
Keywords: | kbvs2005applies kbvs2005swept kbvs2002sp1sweep kbbug kbCtrl kbnofix KB326440 |
---|
|