Converting TreeNode to DataTable Dynamically

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


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)


i am facing difficulty in understanding flow of code for recursive function. any suggestion is appreciated.



Here's a pseudo code, hope it will help you to deal with your problem

private void getNodeList()
    //This will hold your node text
    List<string> nodeTextList = new List<string>();
    //loop through all teeview nodes
    foreach(TreeNode rootNode in treeView.Nodes)
       //Add root node to list
       //Do recursive getter to get child nodes of root node
       getChildNodes(rootNode, nodeTextList);

    //Do with nodeTextList what ever you want, for example add to datatable.

private void getChildNodes(TreeNode rootNode, List<string> nodeTextList)
   foreach(TreeNode childNode in rootNode.Nodes)
       //Add child node text
       getChildNodes(childNode, nodeTextList);

Need Your Help

2 RewriteRule in htaccess


I would like to redirect everything to a.php. And baba to b.php.

Convert javascript function to Obj-C function

javascript objective-c function

I want to use a bunch of functions that were written in Javascript in my Obj-C app. I made a header file and got the first one converted, but got stuck on the second. Here's what I started with and

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.