There are plenty of methods to convert datatable into treeview (treenode) like this. But is there any way to do create a datatable maintaining hierarchy. For ex. if TreeNode
is like
A-A1
-A2-A21
-A22
B-B1
-B2-B21
-B3-B31
-B32-B321
-B322
-B33
-B4
should look like following in datatable. Then i can either save it in the databse or show it to the user in a datagrid
.
All column can have take string
values.
Is there any way so i can pass a treenode
to a function & it will create datatble like this dynamically. treenode
structure will change everytime that's why i can not hardcode it. Suppose i have a recursive function like this.
public void CreateData(TreeNode trn)
{
foreach(TreeNode t in trn.Nodes)
{
CreateData(t);
}
}
i am facing difficulty in understanding flow of code for recursive function. any suggestion is appreciated.
Thanks.