C# - When creating a new object, I would like to set the value of a Boolean Property such that it will show the databound ThreeState CheckBox in its indertminate state. In XAML, I can use IsChecked = "{x:Null}". When the object is read from the DB (Sql), which allows bit values to be Null, I am assuming (haven't tested it yet), the object's Boolean Property will be correctly represented in the CheckBox. But I would like to know how it can be done in code.
Thanks
Jav
After testing the data read from the database, things still didn't work if I used (SafeDataReader)dr.GetBoolean("@FieldName"), because the nulls were converted to false.
However, if I declared my Properties to be bool? instead of bool, and then used (SafeDataReader)dr.GetValue("@FieldName"), nulls from the DB were faithfully represented as nulls in the property values and that did th trick.
Jav
Copyright (c) Marimer LLC