Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
130
Loading DataTree From Code Behind Issue
posted

Hello, I just recently started working with the webdatatree object for asp.net.  I have implemented the ultrawebtree before but never the webdatatree.  My page has the tree as a menu of items the user can click on and populate a frame to the right.  Currently the tree is being populated from a call to the database.  When I hit the database I bring back a text element and a value element to be placed in the nodes.  

My problem however, is that when I go to load the tree inside the page_load function, I call a class that returns a DataTreeNode object.  This object is the root node for my tree.  So I just add that main node to my DataTree.nodes collection.  So inside my class function, I am populating that root nodes, node collection.  

For example purposes here is a mock piece of code that shows whats happening and where my problem lies inside that class function.

public DataTreeNode getDashboardDataTreeNode()

    {        

        DataTreeNode root = new DataTreeNode();
        root.Text = "Main";
        root.Value = "root";

        for(int i=0; i<4; i++)

        {

            DataTreeNode innerNode = new DataTreeNode();

            innerNode.Text = "New";

            innerNode.Value = "val";

            root.Nodes.Add(tCat);

        }

}

 

When I call this function add that node to my DataTreeNode all that shows up is the "Main" node and one "New" node, where I wanted "Main" with four "New" nodes underneath.

I have done this same process with the Asp standard tree and the original UltraWebTree's TreeNode objects, both worked fine.

Any help on this matter would be greatly appreciated.

Thanks.

Parents
No Data
Reply
  • 33839
    Verified Answer
    posted

    arithal ,

    I tried the code you provided.  I reproduced your issue.  We will investigate as to whether this is a bug or not.  But by changing the code slightly, I got your desired result.  You attempt to add the child nodes to the root object before adding to the data tree.  If I first add the root to the data tree and then add the children off of the tree, I get all four children.  Perhaps try doing that. 

                DataTreeNode root = new DataTreeNode();
                root.Text = "Main";
                root.Value = "root";
                this.WebDataTree3.Nodes.Add(root);
                for (int i = 0; i < 4; i++)
                {
                    DataTreeNode innerNode = new DataTreeNode();
                    innerNode.Text = "New";
                    innerNode.Value = "val";
                    this.WebDataTree3.Nodes[0].Nodes.Add(innerNode);
                }

     

    regards,
    David Young

Children