Rendering Sitecore Content Tree

Once we got a requirement to display certain media library items in our page. We have certain controls like DataTreeView in Sitecore which can be extended based on our requirement.

<DataContext ID="TreeviewDataContext" Root=”{3D6658D8-A0BF-4E75-B3E2-D050FABCF4E1}” DataViewName=”Master” />
<DataTreeview ID="Treeview" DataContext="TreeviewDataContext" Root="true"> 

But we faced some challenges in extending DataTreeView.

Another simple and easily extendable solution would be Telerik’s RadTreeView and Sitecore.Resources.ImageBuilder API.

<telerik:RadTreeView ID="contentTree" runat="server" OnNodeDataBound="contentTree_NodeDataBound" ItemType="Sitecore.Data.Items.Item">
protected void contentTree_NodeDataBound(object sender, RadTreeNodeEventArgs e)

private void UpdateTree(RadTreeNode treeNode)
    Item currentItem = (Item)treeNode.DataItem;
    //Binding Icon and Name of Sitecore Item
    HtmlGenericControl nodeContainer = new HtmlGenericControl("div");
    ImageBuilder imageBuilder = new ImageBuilder() { Height = 16, Src = currentItem.Appearance.Icon, Width = 16 };
    nodeContainer.InnerHtml = imageBuilder.ToString() + currentItem.Name;
    //Binding Child Items 
    foreach (Item childItem in currentItem.Children)
        RadTreeNode currentNode = new RadTreeNode() { DataItem = childItem };

Hope this will save you some time, if you are looking out for more customization. Otherwise DataTreeView will help.

Originally Posted at:

Leave a Reply

Your email address will not be published. Required fields are marked *