Reading Data into TreeView from SQL Table
Posted on 2007-03-21
I have a table with Zip Codes in it. From this, I want to create a tree view of data. However, I need to drill down and give people options on what they are allowed to select. My datatable contains 4 columns:
State, County, City, Zip
I want to create a parent node at their level (State, County, or City). and then give them the ability to select anything below them
for instance, I am at a county level. In the tree view, I want to see my county, then all the cities in my county and then all my zip codes in my city. So my tree would look like this:
But, if I am at the state level, I want to be able to have the state as the parent, and then each county under that, and each city....
How can I separate out the parent (I already know what level they are at) and then create all the children. This is all in 1 table.
I do have the table set at the correct level for data reading (meaning I do a select * from table where state='mystate' if I am at state level, select * from table where state='mystate' and county='mycounty' for county level, and so on.