Getting Root Node

3 posts, 0 answers
  1. Andy
    Andy avatar
    16 posts
    Member since:
    Jun 2014

    Posted 04 Jul 2014 Link to this post

    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. Shinu
    Shinu avatar
    17764 posts
    Member since:
    Mar 2007

    Posted 04 Jul 2014 in reply to Andy Link to this post

    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.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Doug
    Doug avatar
    68 posts
    Member since:
    Aug 2014

    Posted 01 Aug 2014 in reply to Shinu Link to this post

    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"))
Back to Top