Master-Detail best practice

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi

I have a sortable single-select read-only datagrid displaying the master list.

Therefore to get the selected item to edit in another windows form, I obtain
the required master DataRow from the Row property of the cast of
myCurrencyManager.Current to a DataRowView.

Is it then best practice to then pass this DataRow into the following
windows form in order to bind it to controls and to bind it's related child
(detail) rows to another readonly datagrid.

Or, is it better to pass in the whole DataTable (1000's of records) and the
primary key ID (from the obtained master DataRow), then perform a Find to get
to the correct record in the DataTable, and bind from there.

I will need to extend the master-detail example to many levels of
master-detail, each opening a further windows form. At each level I need to
be able to Accept or Reject all of the child edits from that point down, i.e
for the current table and all of it's offspring, only accepting all of the
additions, deletions and updates on the final save.

I have the second option above working fine, but it seems odd to have to
re-find the current row each time (due to the sortable datagrid) and to be
passing tables full of data around when I am only concerned with one row. The
first option above seems to throw up ever increasing challenges, e.g. adding
new rows to the DataRows collection returned by the GetChildRows method.

Any pointers would be most welcome.
 
Hi Terry,

First of all, I would like to confirm my understanding of your issue. From
your description, I understand that you need to know the best practice to
pass DataRows and their child rows between forms. If there is any
misunderstanding, please feel free to let me know.

I think, in this case, passing the DataRow reference is fine. When getting
the reference in another form, we can get all the column values from the
DataRow. Then we can also use DataRow.GetChildRows method to return the
child rows. Since all the DataRow is referencing to the same object in
DataSet, the modification to a row will be shown on all forms.

HTH.

Kevin Yu
=======
"This posting is provided "AS IS" with no warranties, and confers no
rights."
 
Back
Top