Help - Programmatically Building a Treeview from Database

T

Teemu

Hello.



Please bear with me if this seems like a basic question (I'm just getting started with all this ASP.NET and WebControls stuff).



Anyway, I'm trying to programmatically build a treeview based off a dataset that I've queried from our database. First, I'm manually creating and adding the "root" node to the treeview control. Then, I'm trying to iterate through my dataset and build all the folders and files under the root node.




An example of the dataset looks like:



Report | MonSite | Category

ReportName13 | Auxi A | <NULL>

ReportName27 | Auxi A | <NULL>

ReportName22 | Auxi B | <NULL>

ReportName14 | <NULL> | Calibration

ReportName25 | <NULL> | Calibration

ReportName16 | Auxi A | Calibration

ReportName17 | Auxi A | Calibration

ReportName18 | Auxi A | Calibration

ReportName1 | Unit 1 | Calibration

ReportName7 | Unit 2 | Calibration

ReportName19 | Auxi B | Downtime

ReportName20 | Auxi B | Downtime

ReportName21 | Auxi B | Downtime

ReportName2 | Unit 1 | Downtime

ReportName8 | Unit 2 | Downtime

ReportName3 | Unit 1 | EDSCMS

ReportName9 | Unit 2 | EDSCMS

ReportName23 | <NULL> | Excess Emission

ReportName26 | <NULL> | Excess Emission

ReportName4 | Unit 1 | Excess Emission

ReportName10 | Unit 2 | Excess Emission

ReportName5 | Unit 1 | Other Summary

ReportName11 | Unit 2 | Other Summary

ReportName6 | Unit 1 | RATA

ReportName12 | Unit 2 | RATA





And, the completed treeview needs to look something like:



Root

[No category] (for the <NULL> category field)

MonSite

Report

Report

MonSite

Report

Category

MonSite

Report

MonSite

Report

Report

Category

MonSite

Report

(etc.)






I'm having the most difficult time doing this. Can someone provide some advice and/or sample code to help me? Any info. would be greatly appreciated.



Thanks.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,483
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top