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

Getting Root Node

2 Answers 36 Views
TreeView
This is a migrated thread and some comments may be shown as answers.
Andy
Top achievements
Rank 1
Andy asked on 04 Jul 2014, 08:22 AM
Hi,

Given a node is it possible to get the value of the root node?

1
    222
    333
        888
5
    555
    444

for exmaple if I was on 888 I need to be able to find 1, likewise if I was on 444 I need to be able to find 5

TIA.

2 Answers, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 1
answered on 04 Jul 2014, 10:24 AM
Hi Andy,

Please try the below c# code for accessing the RootNode of a selected node.

C#:
protected void rtreeviewTestDemo_NodeClick(object sender, Telerik.Web.UI.RadTreeNodeEventArgs e)
{
    if (e.Node.Level == 1)
    {
        RadTreeNode parentNode = (RadTreeNode)e.Node.ParentNode;
        string parentNodeText = parentNode.Text;
    }
    else if (e.Node.Level ==2)
    {
        RadTreeNode parentNode = (RadTreeNode)e.Node.ParentNode.ParentNode;
        string parentNodeText = parentNode.Text;
    }
}

Thanks,
Shinu.
0
Doug
Top achievements
Rank 1
answered on 01 Aug 2014, 09:09 PM
if your able to add an attribute to each node you can just use
Dim node As RadTreeNode = RadTreeView1.FindNodeByAttribute("CategoryId", Request.QueryString("CategoryID"))

in my case I had added this attribute to every node created
Dim a As RadTreeNode = New RadTreeNode
a.Attributes.Add("CategoryId", dr("CategoryId"))
Tags
TreeView
Asked by
Andy
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 1
Doug
Top achievements
Rank 1
Share this question
or