G
Guest
I want to accomplish a DataRelation not only between Parent and Child but
also to a Grandparent.
I thought that would be possible by establishing a Datarelation between
GrandParent and Parent and another one between Parent and Child. Here is part
of the code:
// Fill the dataSet1 with the three tabels Grand, Parent and Child, and then:
DataColumn ColumnGrandIdA;
DataColumn ColumnParentIdA;
DataColumn ColumnParentIdB;
DataColumn ColumnChildIdB;
DataRelation RelationGrandParent;
DataRelation RelationParentChild;
ColumnGrandId = dataSet1.Tables["Grand"].Columns["IdA"];
ColumnParentIdA = dataSet1.Tables["Parent"].Columns["IdA"];
ColumnParentIdB = dataSet1.Tables["Parent"].Columns["IdB"];
ColumnChildIdB = dataSet1.Tables["Child"].Columns["IdB"];
RelationGrandParent = new DataRelation("RelationGrandParent",
ColumnGrandIdA, ColumnParentIdA);
RelationParentChild = new DataRelation("RelationParentChild",
ColumnParentIdB, ColumnChildIdB);
dataSet1.Relations.Add(RelationGrandParent );
dataSet1.Relations.Add(RelationParentChild );
dataGrid1.SetDataBinding(dataSet1, "Grand");
dataGrid2.SetDataBinding(dataSet1, "Grand.RelationGrandParent");
dataGrid3.SetDataBinding(dataSet1, "Parent.RelationParentChild");
Now only the dataGrid2 binding works. If I comment out the line
dataGrid2.SetDataBinding the dataGrid3 binding works.
How do I make the two bindings work simultaneously?
Örjan Leringe
also to a Grandparent.
I thought that would be possible by establishing a Datarelation between
GrandParent and Parent and another one between Parent and Child. Here is part
of the code:
// Fill the dataSet1 with the three tabels Grand, Parent and Child, and then:
DataColumn ColumnGrandIdA;
DataColumn ColumnParentIdA;
DataColumn ColumnParentIdB;
DataColumn ColumnChildIdB;
DataRelation RelationGrandParent;
DataRelation RelationParentChild;
ColumnGrandId = dataSet1.Tables["Grand"].Columns["IdA"];
ColumnParentIdA = dataSet1.Tables["Parent"].Columns["IdA"];
ColumnParentIdB = dataSet1.Tables["Parent"].Columns["IdB"];
ColumnChildIdB = dataSet1.Tables["Child"].Columns["IdB"];
RelationGrandParent = new DataRelation("RelationGrandParent",
ColumnGrandIdA, ColumnParentIdA);
RelationParentChild = new DataRelation("RelationParentChild",
ColumnParentIdB, ColumnChildIdB);
dataSet1.Relations.Add(RelationGrandParent );
dataSet1.Relations.Add(RelationParentChild );
dataGrid1.SetDataBinding(dataSet1, "Grand");
dataGrid2.SetDataBinding(dataSet1, "Grand.RelationGrandParent");
dataGrid3.SetDataBinding(dataSet1, "Parent.RelationParentChild");
Now only the dataGrid2 binding works. If I comment out the line
dataGrid2.SetDataBinding the dataGrid3 binding works.
How do I make the two bindings work simultaneously?
Örjan Leringe