how to get the child nodes

4 posts, 0 answers
  1. kevin
    kevin avatar
    2 posts
    Member since:
    Oct 2008

    Posted 12 Oct 2008 Link to this post

    how to get the child nodes on server-side.

    thanks
  2. Shinu
    Shinu avatar
    17764 posts
    Member since:
    Mar 2007

    Posted 13 Oct 2008 Link to this post

    Hi Kevin,

    Try the following code snippet to get the child nodes on the server side.

    CS:
    protected void RadTreeView1_PreRender(object sender, EventArgs e) 
        { 
            foreach(RadTreeNode parentnode in RadTreeView1.Nodes) 
            { 
                if (parentnode.Expanded) 
                { 
                    RadTreeNode ChildNode1 = (RadTreeNode)parentnode.Nodes[0]; 
                    RadTreeNode ChildNode2 = (RadTreeNode)parentnode.Nodes[1]; 
                } 
            } 
        } 


    Regards
    Shinu.
  3. kevin
    kevin avatar
    2 posts
    Member since:
    Oct 2008

    Posted 13 Oct 2008 Link to this post

    sorry, i want to know.

    for example:

    protected void RadTreeView1_NodeDataBound(object sender, RadTreeNodeEventArgs e)
            {
                how to know the "e.Node" has child nodes?          
            }


    thanks
  4. Shinu
    Shinu avatar
    17764 posts
    Member since:
    Mar 2007

    Posted 14 Oct 2008 Link to this post

    Hi Kevin,

    You can try the following approach to see whether a clicked node has child nodes or not.

    CS:
    protected void RadTreeView1_NodeClick(object sender, RadTreeNodeEventArgs e) 
        { 
            if (e.Node.Nodes.Count == 0) 
            { 
                Response.Write("THIS NODE HAS NO CHILDREN"); 
            } 
            else 
            { 
                Response.Write("THIS NODE HAS  CHILDREN"); 
            } 
        } 


    Go through the following forum discussion which explains more on this regard.
    Node has child or not?

    Thanks
    Shinu
Back to Top