Hi Petro,
You could try having a default value for that column and not allowing null
in the constraints, or you can investigate the DataBinding.Format and
DataBinding.Parse events and use them to convert the value yourself.
Hope that helps.
Regards,
Matt Garven
> When I try to bind a checkbox and the data for the field is null I get an
> error 'Object cannot be cast from DBNull to Other types'. Also when I use
> AddNew I also get the same error. I must allow for 0, 1 or null data.
>
> My code is as follows:
> ckActive.DataBindings.Add(new Binding("checked", dv, "Active"));
petro - 04 Mar 2005 15:49 GMT
Thanks I will try that when I get back around to that project.
> Hi Petro,
>
[quoted text clipped - 13 lines]
> > My code is as follows:
> > ckActive.DataBindings.Add(new Binding("checked", dv, "Active"));
I have exactly same problem.
To fix it, call CurrencyManager.Refresh before you call
CurrencyManager.EndCurrentEdit. Because you need to notify the
underlaying dataset that a new has been added first!
simple.