Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1303
  • Last Modified:

How do I find a TreeNode that has a certain value, and append ChildNodes?

I have a TreeView with a root TreeNode in it already. In my code-behind, I want to take that existing TreeNode, go to a treenode that has a value of "C:\\Temp\first\folder1", then add a childnode underneath it using this.ChildNodes.Add(newTreeNode). How do I find the node with a value of "xxxx"? I'm using ASP.NET 2.0 / C#.
0
bemara57
Asked:
bemara57
  • 2
1 Solution
 
donjon56Commented:

Use the FindNode method of the TreeView

Something like:
TreeNode node = TreeView1.FindNode(myFolderPath);

Here is the documentation from Microsoft:
http://msdn2.microsoft.com/en-us/library/system.web.ui.webcontrols.treeview.findnode.aspx
0
 
donjon56Commented:
Oh....

The second part of your question:

To add a child node do the following:

node.ChildNodes.Add(newTreeNode);
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now