[dba-VB] Problem with LinqToSQL, a listbox, a textbox, and SubmitChanges

Dan Waters df.waters at comcast.net
Wed Jul 20 19:13:56 CDT 2011


In a simple test form, I have a listbox and a textbox. The form is bound to
a datacontext, which has a single table. The listbox has two items, and is
not bound. The textbox is bound to the datacontext.

When I select an item from the listbox, the following code runs:
    txtTest.Text = lstTest.SelectedItems(0).ToString

Then when I push my Save button, the following code runs:
    Me.TextDC.SubmitChanges()

But - the database field which the textbox is bound to is NOT updated.

If I manually type in a value into the textbox and then push the Save
button, the database field IS updated.

I've been trying to solve this on and off for several days, and I finally
made this very simple text form to confirm or deny what was happening. No
errors occur.

So, for some reason SubmitChanges() does not recognize that the textbox
needs to be updated if it's .Text property has been updated from the
listbox, but does recognize that it needs to be updated if I manually type
in a value.

What's the difference?
Dan








More information about the dba-VB mailing list