populating treeview from database table
-
hi , I have a database table with 3 columns table1: eid ename parentid 0 root 0 1 child1 0 2 child2 0 3 gchild1 1 4 gchild2 1 5 gchild3 2 6 gchild4 2 7 ggchild1 3 .... and so on. now i want to populate the ASP.NET tree view with the table entries by querying the eids and parentids. i am using ASP.NET 1.1. so i am using microsoft web controls. TreeView: Root ---child1 ------gchild1 ----------ggchild1 ------gchild2 ---child2 ------gchild3 ------gchild4 and so on..... Can some one point to some logic or to some document.
-
hi , I have a database table with 3 columns table1: eid ename parentid 0 root 0 1 child1 0 2 child2 0 3 gchild1 1 4 gchild2 1 5 gchild3 2 6 gchild4 2 7 ggchild1 3 .... and so on. now i want to populate the ASP.NET tree view with the table entries by querying the eids and parentids. i am using ASP.NET 1.1. so i am using microsoft web controls. TreeView: Root ---child1 ------gchild1 ----------ggchild1 ------gchild2 ---child2 ------gchild3 ------gchild4 and so on..... Can some one point to some logic or to some document.
-
I'll try to make this as simple as possible, it's just to give you some idea... Table "TreeItems": item_id, item_parent, item_caption, item_url Main Code: [Run Query] SELECT * FROM TreeItems WHERE IsNull(item_parent) OR IsEmpty(item_parent) [Loop ResultSet] [Create Parent Node] RecursiveScan(thisnode, item_id); [Add Parent Node to Treeview] [End Loop ResultSet] RecursiveScan (Parent_Node, ParentId) { [Run Query] SELECT * FROM TreeItems WHERE item_parent = @ParentId [Loop ResultSet] [Create Child Node] RecursiveAddNodes(thisnode, item_id); [Add Child Node to Parent] [End Loop ResultSet] } of course you will have to adapt to your custom table settings and to the treeview control you are using, I've never used microsoft web controls before.