Hello
I'm binding untyped DataSet field to checkbox "Checked" property.
(dataset is filled with data from MSSQL database, DB_FIELD can not be NULL)
Here is the code snippet:
b = new Binding("Checked", this.dataSet.Tables[0], DB_FIELD");
b.Format += new ConvertEventHandler(dbnull2null_checked);
b.Parse += new ConvertEventHandler(dbnull2null_checked);
this.myCheckbof.DataBindings.Add(b);
and dbnull2null_checked is following:
protected void dbnull2null_checked(object sender, ConvertEventArgs cevent)
{
if (cevent.Value.Equals(DBNull.Value)) cevent.Value = false;
if (cevent.Value == null) cevent.Value = 0;
}
Unfortunetly, if the user did not changed value of the checkbox,
database gets null (and throws an exception). If value is changed (to
whatever value) everything is fine.
How to fix it? I'm desperate
--
Semper Fidelis
Adam Klobukowski
(E-Mail Removed)