By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
426,083 Members | 1,608 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 426,083 IT Pros & Developers. It's quick & easy.

Updating a databound textbox via its bound field.

P: n/a
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?
Jun 27 '08 #1
Share this question for a faster answer!
Share on Google+

This discussion thread is closed

Replies have been disabled for this discussion.