I am working on tree View in taht i want to do two thinks i.e
1. add new node at run time
2. what data is stored in a database is shown in the tree view as parent node and
its child

for second i have do some coding it shows data as parent and child node but problem is it shows only one row record can any one help me correct the coding please

SqlConnection con = new SqlConnection("USER=userid;PASSWORD=password;SERVER=servername;DATABASE=database");
            string SQLQuery;
            SQLQuery = "select tablename,displayname from Tablename";
            DataSet ds=new DataSet();
            SqlDataAdapter da=new SqlDataAdapter(SQLQuery,con);
            foreach ( DataRow Row in ds.Tables[0].Rows)
                TreeNode Tnode = new TreeNode("ParentNode");


Edited 6 Years Ago by virusisfound: n/a

Hey there,

First of all, in order to add a new PARENT node at runtime you should use this code:

TreeNode parent = new Node;

for a CHILD node:

TreeNode child = new Node;

Now, what has to do with the Data show, then you need to load all the data that you want in a collection(DataTable,List) and then create a recursive function in order to create the treeview structure on all depths.

Hope i helped. :)

Edited 6 Years Ago by Alexpap: n/a

i have database witht these column names id,nodename,nodelevel.
in this i have to add the value to the ultratree from database as parentnode and childnode. for example(state)is a parentnde ,its childnode as (tamilnadu)and(kerala).tamilnadu's childnode as(chennai) and( pondcherry) etc for this i want a ultratree to dispay it

This article has been dead for over six months. Start a new discussion instead.