Data binding and Null Values

G

Guest

When you bind a text box to a field that contains null values the text box
displays an empty string. Great!

My Database field is an integer and I want an empty text box to represent a
NULL value. However the EndEdit event on the datarow returns the error The
input string was in an incorrect format

I have failed to find a way to either trap the empty string in the
rowchanging event and turn it into DBNULL or to programatically manipulate
the value in the field to DBNull.Value when a keypress results in no thext
left in the Textbox.

How? Please, can I comunicate a NULL value back to the datarow with a
databound text box?

Regards

Ben Reese
 
M

Marina

Handle the Parse event of the Binding on your textbox. In it, you can return
dbnull.value if the textbox contains an empty string.
 

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