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.
This works fine as long as you have one level. What I need is to add multiple items in the root and add a new tree to each item in the root.
So, what if I want to add this?
And this is an example, the data to load is dynamic and the amount of levels I have can change constantly. I cannot bind directly to the data, as we have a separate layer between the database and the webapplication. Creating nodes as above, is what I tried, but I have no clue how to do it to for my needs.
You can add as many nodes to a node as you want, it only remembers the last one. I think that's a serious bug in the control. The same happens with WebDataMenu as it uses the same navigationcontrol.
Thank you for the help. I was going to try this today actually but haven't gotten around to it as I've been swamped this morning. I will try this solution out and see if I can reproduce the results.
Again, thank you much.
Chris McMahan
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