SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Enthusiast
    Join Date
    Apr 2006
    Posts
    35
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    how to make a dynamic tree

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

  2. #2
    SitePoint Guru Chroniclemaster1's Avatar
    Join Date
    Jun 2007
    Location
    San Diego, CA
    Posts
    784
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    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.

  3. #3
    SitePoint Wizard
    Join Date
    Feb 2007
    Posts
    1,274
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    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

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •