2

I'm working with the treeview and I've seen that I can get the selected node, but when I try to look for it on TreeView I can't find it because TreeView.Nodes only has rootNode. What's happening?

I'm doing this on the same method:

  • First I get SelectedNode and
  • then I try to get its index using TreeView.Nodes.IndexOf(selectedNode), but Nodes only has rootNode.

This is the defenition of treeview on aspx page:

<asp:TreeView ID="DestinationTree" runat="server"  CssClass="destinationsTree" ExpandDepth="1" 
 onselectednodechanged="DestinationTree_SelectedNodeChanged" 
 ontreenodeexpanded="DestinationTree_TreeNodeExpanded" ShowLines="True" 
 Font-Names="&quot;Segoe UI&quot;,Frutiger,Tahoma,Helvetica,&quot;Helvetica Neue&quot;,Arial,sans-serif">
 <ParentNodeStyle Font-Bold="False" />
 <HoverNodeStyle Font-Underline="True" ForeColor="#5555DD" />
 <SelectedNodeStyle Font-Underline="True" ForeColor="#5555DD" HorizontalPadding="0px" VerticalPadding="0px" />
 <Nodes>

TreeView is inside an Ajax UpdatePanel. I use TreeNodeExpand to add more nodes, and SelectedNodeChange to enable and disable buttons.

Any adviced?

1 Answer 1

1

Every node also has a Nodes property. Use a recursive function to walk the tree to find it.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.