DaniWeb IT Discussion Community

DaniWeb IT Discussion Community (http://www.daniweb.com/forums/)
-   ASP.NET (http://www.daniweb.com/forums/forum18.html)
-   -   add nodes and subnodes to a treeview from sql database by coding in asp.net 2.0 (http://www.daniweb.com/forums/thread73422.html)

rinkuchoudhury Mar 26th, 2007 6:42 am
add nodes and subnodes to a treeview from sql database by coding in asp.net 2.0
 
hi
I have to add nodes and subnodes to a tree view from sql database in asp.net(VB.Net) 2.0

How to do this
i have 3 tables
i want to add nodes from first table and respective childnodes from the 2nd table subsiquent child nodes from the 3rd table

how to do this

f1 fan Mar 26th, 2007 8:15 am
Re: add nodes and subnodes to a treeview from sql database by coding in asp.net 2.0
 
The easiest way is to write a query to select the data from all 3 tables and put them into a dataset with relationships.
Then you just have to iterate through the first table one row at a time and create a node for it. Then run through that rows child rows one at a time and create a node for them and add them to the parent node, and run through each of the child rows of those rows and do the same.
In pseudo code (as i am more a C# than Vb person)
..Create Dataset with 3 tables and 2 relationships
Create a top node
For each table1row in table1
Create table1node
Add it to topnode's node
for each table2row in table1row.getchildrows()
Create table2node
Add it to table1node
for each table3row in table2row.getchildrows()
Create table3node
end table3row for each
end table2row foreach
end table1row foreach


All times are GMT -4. The time now is 9:11 am.

Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC