New to Telerik UI for ASP.NET AJAX? Download free 30-day trial

Determine Last Level of TreeList

Environment

Product RadTreeList for ASP.NET AJAX

Description

In some scenarios with TreeList you might want to execute custom logic only for the innermost level - e.g. hiding or disabling some buttons or applying conditional color.

Solution

You can achieve this requirement using the following method:

protected void RadTreeList1_ItemDataBound(object sender, TreeListItemDataBoundEventArgs e)
{
    if (e.Item is TreeListDataItem)
    {
        TreeListDataItem item = e.Item as TreeListDataItem;

        if (!item.CanExpand)
        {
            // execute custom logic
        }
    }
}
In this article