RadTreeView for ASP.NET

Showing the number of child nodes next to the parent node text Send comments on this topic.
Example scenarios (How to) > Server-side > Showing the number of child nodes next to the parent node text

Glossary Item Box

You can traverse all TreeNodes in the Page_Load event using the GetAllNodes() method of Telerik RadTreeView and add the number of child nodes to the parent node's Text using code similar to the shown below.

Example:

C# Copy Code
...
protected override Page_Load(object sender, EventArgs e)
{
    
if (!Page.IsPostBack)
    {
        ArrayList allNodes = RadTree1.GetAllNodes();

        
foreach (RadTreeNode node in allNodes)
        {
            
if (node.Nodes.Count > 0)
                node.Text = node.Text +
" (" + node.Nodes.Count.ToString() + ")";
        }
    }
}
...