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

how to get the child nodes

3 Answers 100 Views
TreeView
This is a migrated thread and some comments may be shown as answers.
kevin
Top achievements
Rank 1
kevin asked on 13 Oct 2008, 04:50 AM
how to get the child nodes on server-side.

thanks

3 Answers, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 13 Oct 2008, 05:54 AM
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.
0
kevin
Top achievements
Rank 1
answered on 13 Oct 2008, 06:46 AM
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
0
Shinu
Top achievements
Rank 2
answered on 14 Oct 2008, 06:38 AM
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
Tags
TreeView
Asked by
kevin
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
kevin
Top achievements
Rank 1
Share this question
or