This is a migrated thread and some comments may be shown as answers.

FindNodeByValue then Nodes.Add a child?

1 Answer 100 Views
TreeView
This is a migrated thread and some comments may be shown as answers.
Greg
Top achievements
Rank 1
Greg asked on 02 Jul 2012, 11:48 PM
I've used a SQL CTE to build a table that represents my hierarchy and now I'm trying to loop through those records to find the parent node, create a new node object and then append that new node object as a child of the parent node I found.

I've got a radtreeview with a parent node with a value of 0.  I've tried accomplishing this two ways - neither works.

The following compiles without error, but doesn't add the newly created CurrentNode to the node I found in objMyTreeView.  
objMyTreeView.FindNodeByValue("0").Nodes.Add(CurrentNode);

The following will find the parent node, but when I add the CurrentNode to it - I'm adding it to the ParentNode object - not the actual parent node in objMyTreeView.  
RadTreeNode ParentNode = objMyTreeView.FindNodeByValue("0");
ParentNode.Nodes.Add(CurrentNode);

This seems like it should be simple - find the node with the value of the current node's parent, then add my current node as a child of the found node.  Any advice offered would be appreciated.  I must be overlooking something obvious.

~ Greg



1 Answer, 1 is accepted

Sort by
0
Plamen
Telerik team
answered on 05 Jul 2012, 12:54 PM
Hi Greg,

 
I am attaching a sample web page based on the code that you pasted and on this on-line demo that worked properly at my side. Please review it and let me know if you have further questions.

Hope this will be helpful.

Greetings,
Plamen Zdravkov
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
Tags
TreeView
Asked by
Greg
Top achievements
Rank 1
Answers by
Plamen
Telerik team
Share this question
or