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

Michael Maddison michael at ddisolutions.com.au
Wed Jul 20 19:52:16 CDT 2011

I havn't confirmed this but the same would happen when binding with ADO
objects as well. I assume it's a part of the binding process.
IIRC you need to update the underlying entity and it will update the
text property.
I can't test now but I think that should work.


Michael M

-----Original Message-----
From: dba-vb-bounces at databaseadvisors.com
[mailto:dba-vb-bounces at databaseadvisors.com] On Behalf Of Dan Waters
Sent: Thursday, 21 July 2011 10:14 AM
To: 'Discussion concerning Visual Basic and related programming issues.'
Subject: [dba-VB] Problem with LinqToSQL, a listbox, a textbox,and

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:

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?

dba-VB mailing list
dba-VB at databaseadvisors.com

No virus found in this message.
Checked by AVG - www.avg.com
Version: 10.0.1390 / Virus Database: 1518/3777 - Release Date: 07/20/11

More information about the dba-VB mailing list