Reputation: 2155
I've following data table structure -
User ID | User Name | Manager ID
-------------------------------------
1 | ABD | 2
2 | BCD | NULL
3 | KUM | 4
4 | POC | NULL
5 | OJM | 2
In the above table User ID - 2 is the manager of User ID - 1,5 similarly User ID - 4 is the manager of User Id - 3.
How to create self relationship to show hierarchical details of Manager -> Users?
Upvotes: 4
Views: 2343
Reputation: 8511
You have to add nested relation for DataTable as below example -
DataRelation relation = new DataRelation("ParentChild",
result.Tables["Employee"].Columns["UserID"],
result.Tables["Employee"].Columns["ManagerID"],
true);
relation.Nested = true;
result.Relations.Add(relation);
Hope this helps.
Upvotes: 3