all groups > dotnet windows forms databinding > november 2004 >
You're in the

dotnet windows forms databinding

group:

Binding textboxs to dataRow with null fields


Binding textboxs to dataRow with null fields ClydeL
11/30/2004 9:45:02 PM
dotnet windows forms databinding:
I have a number of text boxes bound to fields in a datarow selected from a
dataset. Everything works until one of the fields is null.
Binding a bit field to a checkbox doesn't have this problem.
Re: Binding textboxs to dataRow with null fields Colin R. R. Johnson
12/13/2004 8:49:55 PM
ClydeL,

It sounds like what you need is to add an event handler for the
Binding.Format event. By using an event handler for format you can
replace the NULL with whatever text you want, e.g. "N/A", "(null)", "No
Data" etc.

This also ensures you don't get an error because the binding manager is
trying to set a string property to null.

The reason you don't have a problem with a bit field is because the bit
can either be set to true or false. If the database schema allows for a
null value in the bit field the three state checkbox has a state for null.

There's an example in the VS documentation.

[quoted text, click to view]
AddThis Social Bookmark Button