Update bound windows control

  • Thread starter Thread starter PAUL EDWARDS
  • Start date Start date
P

PAUL EDWARDS

I have a windows form that is bound to a datatable. In VB6
I could just update the field contents and it would be
updated in the database, however if I update the text
property of the control from code it is 50% chance that
the update will make it back to the dataset. If I update
the dataset instead of the form, it does not show on the
form.

Is there a method that should be used?

Thanks
Paul
 
Hi Paul,

Thanks for posting to the newsgroup.

When you say you have a windows form that is bound to a datatable, what do
you mean? What type of data binding are you using to bind a table to the
form itself?

Thanks for clarifying,
bliz
--
Jim Blizzard, MCSD .NET
Community Developer Evangelist | http://www.microsoft.com/communities
Microsoft

Your Potential. Our Passion.

This posting is provided as is, without warranty, and confers no rights.
 
Sorry it's not the form, it's most controls on the form
that are bound to columns in one of the tables in a
dataset.

The databindings.text property for the control
txtSalePrice is set to dsetContract (contract dataset) -
tblContract (contract table) - SalePrice (sale price
column in contact table).

According to an entry in another control I wish to set the
value in the Sale Price control. I also wish to create a
default set of comments to store with the sale depending
on values in several controls.

Hope that's clear.
Thanks
Paul
 
Yes, that helps quite a bit.

Are you sure there's only one record in the dataset? The DataBinding allows
you to bind a list of records to a control that doesn't display multiple
records. Perhaps you're working with a different record in the dataset?

Also, make sure the change is making it back into the dataset itself. Once
the dataset is changed, the bound controls should display the new value
(assuming the control is "pointing to" the record that's been updated).
Perhaps you could set a breakpoint and view the contents of the dataset
after you've changed the data on the screen.

If you're making changes to a textbox and want to update the underlying
dataset it's bound to, you'll have to do that in code, perhaps in a button
click event.

I created a simple test program with a couple of textboxes and a datagrid.
I DataBound the textboxes and the dataGrid to the same dataset. (Used this
approach because I knew a datagrid would update the dataset when I made a
change.) As long as I updated the first record, the changes were
automatically reflected in the textboxes.

Hope this helps,
bliz

--
Jim Blizzard, MCSD .NET
Community Developer Evangelist | http://www.microsoft.com/communities
Microsoft

Your Potential. Our Passion.

This posting is provided as is, without warranty, and confers no rights.
 
Back
Top