How to fill nodes in the treeview control from database anyone can help or is there any article or tutorial for that
thanks!
| SitePoint Sponsor |
How to fill nodes in the treeview control from database anyone can help or is there any article or tutorial for that
thanks!




I don't know of any examples. Everything I've seen on MSDN were examples of hooking the treeview up to a .sitemap, but then I wasn't looking for a database hookup either. I'd start there, and see if they have an example of hooking a treeview up to a sqldatasource.
Whatever you can do or dream you can, begin it.
Boldness has genius, power and magic in it. Begin it now.
Chroniclemaster1, Founder of Earth Chronicle
A Growing History of our Planet, by our Planet, for our Planet.





Code:<asp:TreeView ID="tv" runat="server" />
Code:if (!IsPostBack) { TreeNode n1 = new TreeNode("Node 1"); tv.Nodes.Add(n1); TreeNode n2 = new TreeNode("Node 2"); tv.Nodes.Add(n2); TreeNode n3 = new TreeNode("Node 3"); tv.Nodes.Add(n3); TreeNode n1_1 = new TreeNode("Node 1.1"); n1.ChildNodes.Add(n1_1); }
Also:
A treeview will bind to a hierarchical datasource. An XmlDataSource is a hierarchical datasource, as is a sitemap datasource.
If you google around you will be able to find implementations of other hierarchical datasources which can convert a table (table datasource) to a hierarchical datasource given parent/child relationships.
Bookmarks