We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

dataset.Addrange()

Hi,
I am using Gridgrouping control.
I have parent-child relationship in my gridgrouping control.
First time it works fine but when I create relation for another row then
 

ds.Tables.AddRange(new DataTable[]{parenttable,childtable})

method gives me the error of "Datatable 'Table1' is already belongs to this dataset".

Please give me any solution regarding to this.

Regards,

Rasika


3 Replies

MK Muthukumar Kalyanasundaram Syncfusion Team November 4, 2014 02:18 PM UTC

Hi Rasika,

 

Thank you for your interest in Syncfusion products.

 

We would like to let you that at first  you can added all table to the dataSet, then relations between the tables are made and added to the dataSet. The dataSet is then assigned as the datasource of the grid. The GridGroupingControl itself creates the nested structure of the tables directly from the information in the dataset. Please refer the below code,

 

Code:

 

DataTable parentTable = GetParentTable();

DataTable childTable = GetChildTable();

DataTable grandChildTable = GetGrandChildTable();

DataSet ds = new DataSet();

ds.Tables.AddRange(new DataTable[] { parentTable, childTable, grandChildTable });

DataRelation parentToChild = new DataRelation("ParentToChild", parentTable.Columns["parentID"], childTable.Columns["ParentID"]);

DataRelation childToGrandChild = new DataRelation("ChildToGrandChild", childTable.Columns["childID"], grandChildTable.Columns["ChildID"]);

ds.Relations.AddRange(new DataRelation[] { parentToChild, childToGrandChild });

this.gridGroupingControl1.DataSource = parentTable;

 

Please let us know if you have any concern.

 

Regards,

Muthukumar K


Attachment: Parent__Child_relation_61025470.zip


RA Rasika November 5, 2014 12:10 PM UTC

Hello Muthukumar Kalyanasundaram ,

Thank You!

It works as expected.

Regards,
Rasika


MK Muthukumar Kalyanasundaram Syncfusion Team November 6, 2014 02:33 PM UTC

Hi Rasika

 

We are glad to hear that the reported issue has been resolved. Please let us know if you need any further assistance.

 

Regards,

Muthukumar K


Loader.
Up arrow icon