468,753 Members | 1,131 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,753 developers. It's quick & easy.

getting 'real' table datasource from grandchild datagrid that is based on dataview

I have a datagrid that is two levels down from the dataview (i.e.
grandchild). I have spent 3 hours trying to get the syntax of determining
it's real datasource (i.e. not it's source based on it's relationship with
the dataview).

argh!

company
---> person
--->contact
-contact is the 'real' datasource for the grid
-company is a dataview used to populate several text controls on the form
and is the binder that the navigation ctrls use.
-the datagrid binds to the dataview with the datamember set to
"companyPerson.PersonContact" which of course is the relationship name
between the dv and the grandchild table.

Of course - if is do the following:
mydatatable = ctype(me.mydatagrid, dataview).table.tablename I get the
Company table! which is NOT what I need.

Is there a simple way of determing that the underlying table my datagrid is
hitting is 'contact' ?

Thank you.
Nov 21 '05 #1
3 1419
Astro,

From a parent row you can get the childcollection of datarows.

http://msdn.microsoft.com/library/de...drowstopic.asp

In a datarow you can find in what table it is.
dr.table

That table is the complete table not the collection of the datarows which
are in the relation.

I hope this helps,

Cor

"astro" <as***@mnrr.com> schreef in bericht
news:5M*********************@tornado.rdc-kc.rr.com...
I have a datagrid that is two levels down from the dataview (i.e.
grandchild). I have spent 3 hours trying to get the syntax of determining
it's real datasource (i.e. not it's source based on it's relationship with
the dataview).

argh!

company
---> person
--->contact
-contact is the 'real' datasource for the grid
-company is a dataview used to populate several text controls on the form
and is the binder that the navigation ctrls use.
-the datagrid binds to the dataview with the datamember set to
"companyPerson.PersonContact" which of course is the relationship name
between the dv and the grandchild table.

Of course - if is do the following:
mydatatable = ctype(me.mydatagrid, dataview).table.tablename I get the
Company table! which is NOT what I need.

Is there a simple way of determing that the underlying table my datagrid
is hitting is 'contact' ?

Thank you.

Nov 21 '05 #2
Hi,

"astro" <as***@mnrr.com> wrote in message
news:5M*********************@tornado.rdc-kc.rr.com...
I have a datagrid that is two levels down from the dataview (i.e.
grandchild). I have spent 3 hours trying to get the syntax of determining
it's real datasource (i.e. not it's source based on it's relationship with
the dataview).
Why say "real" datasource ? When you bind the DataGrid to a DataView and set
DataMember to "relation1.relation2" then it's still using the original
grandchild DataTable (got from da.Fill). There is a DataView inbetween used
to filter the child rows depending on the current parent row.

You can get the DataView for the visible DataTable in the DataGrid
(grandchild in this case) using the CurrencyManager:

Dim cm as CurrencyManager = DirectCast( _
BindingContext( mygrid.DataSource, _
mygrid.DataMember ), CurrencyManager )

Dim currentDataView As DataView = _
DirectCast( cm.List, DataView )

Dim currentDataTable As DataTable = _
currentDataView.Table
Now, currentDataTable is the same DataTable as the one you can get from the
DataView DataSource and the Relations.
hth,
greetings


argh!

company
---> person
--->contact
-contact is the 'real' datasource for the grid
-company is a dataview used to populate several text controls on the form
and is the binder that the navigation ctrls use.
-the datagrid binds to the dataview with the datamember set to
"companyPerson.PersonContact" which of course is the relationship name
between the dv and the grandchild table.

Of course - if is do the following:
mydatatable = ctype(me.mydatagrid, dataview).table.tablename I get the
Company table! which is NOT what I need.

Is there a simple way of determing that the underlying table my datagrid
is hitting is 'contact' ?

Thank you.

Nov 21 '05 #3
Thanks Cor and Bart - I decided to just avoid this problem by adding the
tablename to the tag property of each datagrid on this form.

I have saved your comments and will tackle this issue on project #2.

)
"astro" <as***@mnrr.com> wrote in message
news:5M*********************@tornado.rdc-kc.rr.com...
I have a datagrid that is two levels down from the dataview (i.e.
grandchild). I have spent 3 hours trying to get the syntax of determining
it's real datasource (i.e. not it's source based on it's relationship with
the dataview).

argh!

company
---> person
--->contact
-contact is the 'real' datasource for the grid
-company is a dataview used to populate several text controls on the form
and is the binder that the navigation ctrls use.
-the datagrid binds to the dataview with the datamember set to
"companyPerson.PersonContact" which of course is the relationship name
between the dv and the grandchild table.

Of course - if is do the following:
mydatatable = ctype(me.mydatagrid, dataview).table.tablename I get the
Company table! which is NOT what I need.

Is there a simple way of determing that the underlying table my datagrid
is hitting is 'contact' ?

Thank you.

Nov 21 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

3 posts views Thread by sam | last post: by
8 posts views Thread by ASP Yaboh | last post: by
4 posts views Thread by jaYPee | last post: by
4 posts views Thread by Richard Fagen | last post: by
7 posts views Thread by Brett Romero | last post: by
reply views Thread by zhoujie | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.