views:

82

answers:

1

Hello!

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  A: 

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

Jay
Thanks. I found the solution here: http://forums.asp.net/t/1303960.aspx
VansFannel