A simple binding question

  • Thread starter Thread starter Doug Lowe
  • Start date Start date
D

Doug Lowe

Hi all, this might be a simple question, but then again maybe not. I'm
binding a text box in a Windows form to a column that does not allow nulls.
The problem is, if I do AddNew, the user leaves the field blank, and I call
EndCurrentEdit, I get a "null not allowed" exception. What I want is to put
an empty string in the column. Is there something I'm overlooking?

--Doug
 
Try setting the content of your text field to "" after invoking your AddNew
call

AddNew()
txtMyField.Text = ""

Regards

Shane
 
Thanks, Shane. That doesn't help though. I still get the exception. It does
work if I set the text box to " " (one space) but that's not at all what I
want.

The exception is happening before I get to the EndCurrentEdit method
call...before the click event handler is called, in fact. It must be burried
somewhere in the binding manager. Its as if the binding manager is looking
at my text box, seeing that I didn't enter anything, and trying to set the
bound column to null even though the column doesn't allow nulls.

I hope I'm missing something real obvious :)

--Doug
 
Hey,

Try to create a default constraint on the column. for instance 'N/A' or
'UNKNOWN'
 
Back
Top