Link to home
Start Free TrialLog in
Avatar of jjliu4492
jjliu4492

asked on

How to populate a TreeView control from database

I have a VS2010 C# Windows application, and I want to add a TreeView control to the form. I want to populate the TreeView control with data from tables within my SQL Server 2008 database.For example, my TreeView will have three nodes: Projects, Deliverables, and Times. Under each of these nodes, I want to pull data from the database, and add the data to each node. For Projects, the data will be pulled from "SELECT * FROM dbo.Projects", for Deliverables, the data will be pulled from "SELECT * FROM dbo.Tasks", and for Times, the data will be pulled from "SELECT * FROM dbo.WeekEndingDates". How would I go about doing? Another question I have is: once these nodes are populated, is there a way to change them upon user selection? For example, if a user selects "Project 1" under the Projects node, can the Deliverables node be repopulated with all the data from the database that is associated with "Project 1"? Example: User selects "Project 1" from Projects node, and then the Deliverables node is populated with "SELECT * FROM dbo.Tasks WHERE Project = 'Project 1'".
ASKER CERTIFIED SOLUTION
Avatar of Bob Learned
Bob Learned
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial