Binding INTEGER and use of NULL

G

Guest

Hi

I bind a textbox to a field in the database through CurrencyManager. Everything works find exept one thing: I cannot type Null, blank, nothing in the textfield. The property in the database allows NULL but I cannot type blank in the textbox. Whatever I type that isn't numeric is changed then I leave the textbox

There must be an easy way to solve this - but what?

/Raymond
 
M

Miha Markic [MVP C#]

Hi Raymond,

You might use Binding.Parse event. Example:
textBox1.DataBindings[0].Parse += new ConvertEventHandler(Form1_Parse);

private void Form1_Parse(object sender, ConvertEventArgs e)

{

if (e.Value.ToString() == string.Empty)

e.Value = DBNull.Value;

}


--
Miha Markic [MVP C#] - RightHand .NET consulting & development
miha at rthand com
www.rthand.com

Raymond said:
Hi.

I bind a textbox to a field in the database through CurrencyManager.
Everything works find exept one thing: I cannot type Null, blank, nothing in
the textfield. The property in the database allows NULL but I cannot type
blank in the textbox. Whatever I type that isn't numeric is changed then I
leave the textbox.
 

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