Question populate a treeview by getting the data from the database

Joined
May 9, 2009
Messages
2
Programming Experience
Beginner
to populate a treeview by getting the data from the database
i have threee tables
table1: Maincountry
columns: id,Countryname

table2: Country
columns: country,state


table2: State
columns: state,cities

i want the tree view to be like this

-country1
-State1
-city1
-city2
-state2
-city1
-city2
-country2
-State1
-city1
-city2
-state2
-city1
-city2

what is to be done i want the code please its urgentttttt

thanks in advance
 
Last edited by a moderator:
Please post in the most appropriate forum for the topic, not just the first one you come to. Moved.

There are various things you could do, although they would all be similar. I would suggest you populate three DataTables in the same DataSet with your data and create DataRelations between them. You can then loop through the Country table and for each row you create a node and then get the child rows from the State table. You'd then loop through those and for each row you'd add a node to the parent node and then get the child rows from the City table and do the same thing.

So, what have you got so far? Can you get the data from the database?
 
Back
Top