I have a textbox that represents a primary key in my database. Because the values are nvarchars I can't automatically increment for a new insert. Instead I have to read a value from a drop-down, perform some magic, and create a new incremented value for the new insert.
I've written codebehind that does all this when the drop-down is selected. It works, in that it puts correct values into the textbox. However when I try to insert, I get an error that that field cannot be null.
I'm pretty sure it's because I'm doing this in the codebehind :
myTextBox.text = newValue
which wipes out the binding the textbox should have :
How can I calculate the needed value for this field programmatically and set it back to the screen so the user can see it (and possibly override it) and still keep the databinding intact so I can create the new record?