getting parent and child tables from datagrid

  • Thread starter Thread starter astro
  • Start date Start date
A

astro

Can someone show my example syntax that gets pointers to both the parent and
child tables of a datagrid on a form showing a child table? The datasource
is a dataview, the datamember is the relationship name (e.g. 'OrderDetail')

i.e.....(air code following)

dim dtParent as dataTable
dim dtChild as dataTable

dtParent = mygrid.....
dtChild = mygrid

thank you.
 
Hi,

astro said:
Can someone show my example syntax that gets pointers to both the parent
and child tables of a datagrid on a form showing a child table? The
datasource is a dataview, the datamember is the relationship name (e.g.
'OrderDetail')

i.e.....(air code following)

dim dtParent as dataTable
dim dtChild as dataTable

If you know DataSource is a DataView, then you can do:
dtParent = DirectCast(mygrid.DataSource, DataView).Table

And if you know that DataMember is a relation, then you can do:
dtChild = dtParent.ChildRelations(mygrid.DataMember).ChildTable

I'm not sure why you would want to do this, you will end up with the same
tables you filled with the DataAdapters.

hth,
greetings
 
thank you - that worked )

Bart Mermuys said:
Hi,



If you know DataSource is a DataView, then you can do:
dtParent = DirectCast(mygrid.DataSource, DataView).Table

And if you know that DataMember is a relation, then you can do:
dtChild = dtParent.ChildRelations(mygrid.DataMember).ChildTable

I'm not sure why you would want to do this, you will end up with the same
tables you filled with the DataAdapters.

hth,
greetings
 
Back
Top