Parent-Child-Relation and DataView - .net 2.0

  • Thread starter Thread starter Rolf Welskes
  • Start date Start date
R

Rolf Welskes

Hello,
I have the following problem:
I have tableA, tableB
A relation between tableA and TableB.
So table B is the child of table A.
In tableA, tableB may keyX be the foreingn key and Fk_tableA_tableB the
relation.

Now I have a DataView dvA pointed to tableA.
Now I take a bindingSource bs and set:
bs.DataSource = dvA.
Now I set dataGridViewA.DataSource = bs.
Further I set
dataGridViewB.DataSource = bs.Fk_tableA_tableB.

So I get dvA seeing in dataGridViewA (Parent). as dvA.
Further
I see in dataGridViewB the child-rows of a row selected in tableA / dvA/
datagridA .
Fine.
But
now I have dvB a dataView for the child.
I want to use this DataView for my child.
But I do not know how.

Means:
I want for tableA and tableB have dataView dvA to tableA and dvB have to
tableB, but
on the other side I want with dvB not see all Rows of tableB, but only the
child rows of a row of tableA.

What can I do?

Thank you for any help.
Rolf Welskes
 
Hi Rolf,

According to your description, you want for tableA and tableB have dataView
dvA to tableA and dvB have to tableB, but dvB only see the child rows of a
row of tableA.

I'm afraid there is no relation between two dataviews. To your scenario, I
suggest you may look up Filter property of BindingSource.

Set dvA for TableA, and add BindingSourceTableA. Set datasoure of
BindingSourceTableA to dvA.
Drag a new BindingSourceTableB onto designer surface, Set datasource of
BindingSourceTableB to dvA, set datamember to "Fk_tableA_tableB".

Type the express (which used for filtering the rows of TableB) into Filter
property of BindingSourceTableB.

Please try this method and let me know whether this is what you need. I'm
glad to assist you.

Hope this helps,
Sincerely,
Wen Yuan
 
Hello,
thank you for the informations,
it works fine.
Thank you again and best regards
Rolf Welskes
 
Back
Top