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

Expand to Single Node when using DataBind()?

1 Answer 61 Views
TreeView
This is a migrated thread and some comments may be shown as answers.
Xorcist
Top achievements
Rank 1
Xorcist asked on 30 Nov 2010, 06:16 PM
Currently all my data is being bound through a custom Hierarchy class, I'm having a bit of trouble expanding the structure to make the node I want visible... well... visible. I attempted to use MyTreeView.Nodes(MyIndex).Expanded = True directly after calling MyTreeView.DataBind() but it keeps telling me the index is out of range... but I'm fairly certain it is not. How would one go about expanding a single node of a TreeView without building it from scratch node by node.

* My Bad, I forgot the Node structure was recursive. So I really needed to be working off MyTreeView.Nodes(0). I worked up a little code to get the results I needed, where "selected" is a string value for the text associated with the node I want to expand to:

    Dim Node as RadTreeNode
    Node = rtvHierarchy.FindNodeByText(selected)
    Node.Selected = True
    Node = Node.ParentNode
    do while not (Node is Nothing)
      Node.Expanded = True
      Node = Node.ParentNode
    loop

1 Answer, 1 is accepted

Sort by
0
Yana
Telerik team
answered on 02 Dec 2010, 09:50 AM
Hello,

You can use ExpandParentNodes() method of RadTreeNode to expand its parent nodes.

All the best,
Yana
the Telerik team
Browse the vast support resources we have to jumpstart your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.
Tags
TreeView
Asked by
Xorcist
Top achievements
Rank 1
Answers by
Yana
Telerik team
Share this question
or