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

Data Bindings

  • Politics
    • CNN
    • NBC
    • ABC
  • Sports
    • US Sports
    • European Sports
  • Events
    • Oscar Awards
    • MTV Movie Awards

The DataBindings collection lets you provide different sets of data bindings to the nodes on different levels of the treeview. You can even bind the nodes on each level of the treeview from different tables in a DataSet.

This example demonstrates how to use databindings to apply declarative mapping of data fields to treeview node properties.
<telerik:RadTreeView runat="server" ID="RadTreeView1" DataSourceID="SqlDataSource1"
DataFieldID="id" DataFieldParentID="parentID" Skin="Vista" CheckBoxes="true">
	<DataBindings>
		<telerik:RadTreeNodeBinding TextField="Text" />
		<telerik:RadTreeNodeBinding 
			Depth="0" 
			Checkable="false" 
			TextField="Text" 
			Expanded="true"
			CssClass="rootNode" 
		/>
	</DataBindings>
</telerik:RadTreeView>
  • DefaultCS.aspx
<%@ Page Language="C#" AutoEventWireup="true"  Inherits="Telerik.QuickStart.QsfPage" %>

<%@ Register TagPrefix="telerik" Namespace="Telerik.Web.UI" Assembly="Telerik.Web.UI" %>
<!DOCTYPE html>
<html xmlns='http://www.w3.org/1999/xhtml'>
<head runat="server">
    <title>Telerik ASP.NET Example</title>
    <style type="text/css">
        .rootNode {
            font-size: 13px;
            font-weight: bold;
        }
    </style>
</head>
<body>
    <form id="form1" runat="server">
    <telerik:RadScriptManager runat="server" ID="RadScriptManager1" />
    <telerik:RadSkinManager ID="RadSkinManager1" runat="server" ShowChooser="true" />
    <div class="demo-container size-thin">
        <telerik:RadTreeView RenderMode="Lightweight" runat="server" ID="RadTreeView1"  DataSourceID="SqlDataSource1"
            DataFieldID="id" DataFieldParentID="parentID" CheckBoxes="true">
            <DataBindings>
                <telerik:RadTreeNodeBinding TextField="Text"></telerik:RadTreeNodeBinding>
                <telerik:RadTreeNodeBinding Depth="0" Checkable="false" TextField="Text" Expanded="true"
                    CssClass="rootNode"></telerik:RadTreeNodeBinding>
            </DataBindings>
        </telerik:RadTreeView>
    </div>
    <asp:SqlDataSource runat="server" ID="SqlDataSource1" ConnectionString="<%$ ConnectionStrings:TelerikConnectionString %>"
        SelectCommand="SELECT id, text, parentId from Links"></asp:SqlDataSource>
    </form>
</body>
</html>

Support & Learning Resources

Find Assistance