DropDownTree - Declarative DataSource

SiteMapDataSource

  • All

ObjectDataSource

  • UI for ASP.NET Ajax
  • UI for Silverlight

SqlDataSource

  • Fuller
Isolate this demo as a stand-alone application
  • About this demo
  • C#
  • VB
RadDropDownTree supports binding to various types of data sources, including declarative datasources.

Some of the declarative data sources like the XmlDataSource and the SiteMapDataSourceare inherently hierarchical. Therefore when data-bound to these types of data sources, RadDropDownTree automatically creates the node hierarchy. There is no need to use the DataFieldID and DataFieldParentID properties.

RadDropDownTree supports binding to an ObjectDataSource as well. In addition to the standard Entry properties (Text, Value, etc.) that can be bound to the underlying business objects, the DataFieldID and DataFieldParentID properties can be specified, too. In this way, RadDropDownTree can create a hierarchy of Entries.

Still, the business objects should provide the data needed for the RadDropDownTree to build the hierarchy. If the ParentID property of the business objects are of nullable or reference type, then null values denote root Entry. In case, the ParentID property is of value type (Integer, Guid, etc.), '0'/'Guid.Empty' values denote the root Entry.

  • DefaultCS.aspx
  • DefaultCS.aspx.cs
  • styles.css
<%@ Page AutoEventWireup="false" CodeFile="DefaultCS.aspx.cs" Inherits="DropDownTree.Examples.PopulatingWithData.DeclarativeDataSource.DefaultCS"Language="c#"  %>

<%@ Register TagPrefix="telerik" Namespace="Telerik.Web.UI" Assembly="Telerik.Web.UI" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns='http://www.w3.org/1999/xhtml'>
<head runat="server">
    <title>Telerik ASP.NET Example</title>
    <link rel="stylesheet" type="text/css" href="styles.css" />
</head>
<body>
    <form id="form1" runat="server">
    <telerik:RadScriptManager runat="server" ID="RadScriptManager1" />
    <telerik:RadSkinManager ID="RadSkinManager1" runat="server" ShowChooser="true" />
    <div class="demo-containers">
        <div class="demo-container size-thin">
            <h2>SiteMapDataSource</h2>

            <telerik:RadDropDownTree RenderMode="Lightweight" ID="RadDropDownTree1" runat="server" Width="300px" DefaultMessage="Please select"
                DataSourceID="SiteMapDataSource1" OnNodeDataBound="RadDropDownTree1_NodeDataBound">
            </telerik:RadDropDownTree>
        </div>
        <div class="demo-container size-thin">
            <h2>ObjectDataSource</h2>

            <telerik:RadDropDownTree RenderMode="Lightweight" ID="RadDropDownTree2" runat="server" Width="300px" DefaultMessage="Please select"
                DataSourceID="ObjectDataSource1" DataFieldID="ID" DataFieldParentID="ParentID"
                DataTextField="Text">
            </telerik:RadDropDownTree>
        </div>
        <div class="demo-container size-thin">
            <h2>SqlDataSource</h2>

            <telerik:RadDropDownTree RenderMode="Lightweight" ID="RadDropDownTree3" runat="server" Width="300px" DefaultMessage="Please select"
                DataFieldID="EmployeeID" DataFieldParentID="ReportsTo" DataTextField="LastName"
                DataSourceID="SqlDataSource1">
            </telerik:RadDropDownTree>
        </div>
    </div>
    <asp:SiteMapDataSource ID="SiteMapDataSource1" runat="server"></asp:SiteMapDataSource>
    <asp:ObjectDataSource ID="ObjectDataSource1" runat="server" SelectMethod="GetSiteData"
        TypeName="Telerik.Web.Examples.SiteDataItem"></asp:ObjectDataSource>
    <asp:SqlDataSource runat="server" ID="SqlDataSource1" ConnectionString="<%$ ConnectionStrings:NorthwindConnectionString %>"
        SelectCommand="SELECT * From Employees"></asp:SqlDataSource>
    </form>
</body>
</html>

Support & Learning Resources

Find Assistance

Help Us Improve

Was this example helpful?