Can't update a Child tbl from bound textbox, but can from Child datagrid

L

Larry Woods

I have a Parent-Child situation (defined in one dataset, with a relation
defined); let's say Customers-Orders. I can display Cust-Orders just fine
in two datagrids. I have an "Update" button that checks for changes in the
dataset and if so then updates the dataset. Since I have a lot of fields in
the Child table, I only display a few of the fields in the Child datagrid,
and display ALL of the Child fields in a set of textboxes that are bound to
the Child table through the Parent-Child relation. Again, all displays
fine. If I click on a row of the Child datagrid, all of the approriate
fields are displayed in the textboxes. Then I change a field value in one
of the textboxes. The changed field value appears in the Child datagrid, as
expected. BUT, when I click the Update button, when I check for dataset
changes there AREN'T ANY! IOW, the "changes" dataset is Nothing. I can go
back and make the SAME change directly into the Child datagrid and then
there ARE dataset changes defined in the "Update" procedure.

First, any ideas on what's happening? But, more importantly, how do I get
my textbox changes to be reflected as dataset changes in my Update
procedure?

TIA,

Larry Woods

Here is a code snippet of what I am doing in the Update procedure:

Dim objDataSetChanges As myDataset = New myDataset
'Stop any current edits.
Me.BindingContext(myDataset , "tblParent").EndCurrentEdit()
Me.BindingContext(myDataset , "tblChild").EndCurrentEdit()
'Get the changes that have been made to the main dataset.
objDataSetChanges = CType(myDataset.GetChanges, myDataset)
'Check to see if any changes have been made.
If (Not (objDataSetChanges) Is Nothing) Then
..........
 
C

Cor Ligthert

Larry,

Because of your previous question I can probably answer this very easy.

When you use databinding on a textbox as you do, than the data is pushed
down in the datatable (the one which has to be updated) after that the
currencymanager.position has changes (your listbox).

To force that you can use when table(0) is your datasource the
\\\
BindingContext(ds.Tables(0)).EndCurrentEdit()
///

I hope this helps?

Cor
 
L

Larry Woods

Thanks, Cor....

Now, how about this question:

I have a situation where I am creating a new record---again, but this time
using a group of textboxs. But one of the fields is (1) NOT being input by
the user. It's an IDENTITY that I got from an earlier INSERT but it needs
to be put into the record that I am about to update (a foreign key). I CAN
add a bound textbox to the form (0 width;0 length) and store the foreign key
into it. That works but there MUST be a more "professional" way to do this.

????????????

TIA,

Larry
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top