Data binding and DBNULL

A

Adam Klobukowski

Hello

I have an untyped DataSet that I'm binding data into my form controls.
Binding works well (ie. no this.controll.DataBindings.Add throws an
exception) but when form is shown and some fields of a current row of
the dataset are DBNNULLs I have an exception that I cannot cast DBNULL
to other types...

What can I do to avoid this exception?
 
D

Dmitriy Lapshin [C# / .NET MVP]

Hello Adam,

What if you attach custom handlers to the DataBindings' Format and Parse
events and provide proper DBNull handling in these events?
I even think handling Format only will be enough if you don't need to
convert some pre-defined values typed by the user to DBNull.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top