Problem updating child table from datagrid to dataset

P

pete matthews

HI. I have a dataset with two tables. Table 1 is parent and table 2 is
child. Am populating a single datagrid with records from child table
derived from a single parent record. I am then allowing users to edit
child records in datagrid. Users have an update option for each row in
the datagrid. How do I then update the datagrid details to the dataset
and find the correct child record identity in the dataset.
??? I dont seem to have the currentindex of the child records ?? Any
help greatly appretiated as I tearing out hair. Many thanks. Pete.
 
W

W.G. Ryan eMVP

If the grid is bound to the child datatable than any changes you make in the
grid will be reflected in the underlying table. Just to verify though, you
are using a datarelation right? As far as finding the index though - I'm
not sure I follow you, could you elaborate a little more?
 
P

pete matthews

Hi there. Thanks for that.

Yes there is a relationship in place linking the two tables in the
dataset. Is just a simple one to many. I am populating the datagrid
using the following
Dim CRInt As Integer = mainedit.currentrowINT

If (CRInt - 1) <> -1 Then


'Dim array As DataRow()
'array =
DataGrid1.DataSource = Useract1.TBLschema(CRInt -
1).GetChildRows("TBLschemauseractivity")

DataGrid1.DataBind()
Label4.Text = mainedit.itemdetailsSTR


End If

This works fine and populates my datagrid with the child records for the
parent record number supplied.

I have a template coloumn in the datagrid which has an update button.
The only field users can change is a tickbox coloumn. They press update
button and this triggers the itemcommand successfully.

It is at this point that i need to get the changes from the selected row
and update the child row affected, but I am confused ( to say the least
) about how to update the correct row in th child table in dataset.

Then it would be a simple case of updating the main DB with the DA.

Many thanks

Pete
 

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