Click here to Skip to main content
15,887,812 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi All,

I am using Treeview control in Master page left hand side and right hand side using user control to display existing product as per selected node in treeview. Ex:
>Mobile
>Samsung
>Nokia
>Motorola
>TV
>Onida
>Samsung

Problem: I want to display all the child product comes under one parent node in Datalist user control and same for the other selected parent and child node as well. All the data should come from SQL server table in treeview as well as user control.

But I have no clue how to do? Can anyone help me to come out from this?

Could you provide me the link or C# code(I'm using C# with ASP.NET 4.0)?
Posted

1 solution

1) Catch TreeView.SelectedNodeChanged[^] event and get the value of TreeNode.Text[^]
2) Write and execute a query like this:
SQL
SELECT * 
FROM Products
WHERE ProductName = @prodname

3) Read data returned by query and add new nodes for selected node.

Alternative:
Populating a TreeView Control from the Database[^]

More at:
http://www.dreamincode.net/code/snippet922.htm[^]
http://www.dotnetspider.com/resources/30981-Binding-Treeview-from-database.aspx[^]
http://www.eggheadcafe.com/articles/treeview_databinding.asp[^]
 
Share this answer
 
Comments
VJ Reddy 7-Jun-12 12:27pm    
Good points. 5!
Maciej Los 7-Jun-12 12:34pm    
Thank you, VJ ;)
Sandeep Mewara 7-Jun-12 14:48pm    
Good answer. 5!
Maciej Los 7-Jun-12 14:51pm    
Thank you, Sandeep ;)

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900