So here's the situation (.NET 2.0 btw):
I have a form, and on this form is a textbox among many other
databound controls. The textbox is bound to a field in a data table
via the Text property. In this table there are multiple columns that
cannot be NULL, which, are bound to other controls (but they're not
really important at this time).
I create a new row via the currency manager like so:
_currencyManager.AddNew()
_currentRow = CType(_currencyManager.Current, DataRowView).Row
I have code in the OnLoad event that modifies the bound field
programmatically:
protected overrides sub MyForm_OnLoad(blah blah blah)
if (newRecord) then
_currentRow("TheTextBoxField") = "SOME VALUE!"
end if
end sub
The other controls/fields are blank (and they're supposed to be
empty), even if their fields require data (I do validation for this
later on).
I've read that updating the backing field is the correct way to update
a bound control because the control relies on validation to commit its
value to the field (I know you can change the binding update event to
OnPropertyChanged or what have you, but let's leave it at the default
and use validation). I assume this is the correct procedure when
updating bound data programmatically?
The problem:
Now. The issue is that when I update the backing field the textbox
does NOT get updated. It's blank. I know for sure the data is there
because in the Immediate window _currentRow("TheTextBoxField") returns
"SOME VALUE!". Shouldn't this update the textbox Text field
automatically (seeing as it's bound to that property, yes, I've double
checked)? Would having controls with empty (NULL) values bound to non-
NULL fields cause an issue with this? Would calling it in the OnLoad
event cause any problems with this?