SiteMap

RadSiteMap supports binding to various types of data sources, including declarative datasources.

The most common scenario is to use RadSiteMapDataSource or SiteMapDataSource that are inherently hierarchical.

You can use an ID-ParentID relation to establish a hierarchy among the nodes when binding to non-hierarchical data sources such as SqlDataSource and ObjectDataSource. Specify such relation by using the DataFieldID and DataFieldParentID properties.

  • DefaultCS.aspx
  • SiteDataItem.cs
  • styles.css
<%@ Page Language="C#" AutoEventWireup="true"  %>

<%@ 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>
    <link href="styles.css" rel="stylesheet" type="text/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-container size-medium">
        <ul class="sitemap-list">
            <li class="sitemap-item" style="border: none">
                <div class="text">
                    SqlDataSource</div>
                <telerik:RadSiteMap runat="server" ID="RadSiteMap1" DataSourceID="SqlDataSource1"
                    DataFieldID="ID" DataFieldParentID="ParentID" DataTextField="Title" ShowNodeLines="true">
                    <DataBindings>
                        <telerik:RadSiteMapNodeBinding NavigateUrl="#"></telerik:RadSiteMapNodeBinding>
                    </DataBindings>
                </telerik:RadSiteMap>
            </li>
            <li class="sitemap-item">
                <div class="text">
                    ObjectDataSource</div>
                <telerik:RadSiteMap runat="server" ID="RadSiteMap2" DataSourceID="ObjectDataSource1"
                    DataFieldID="ID" DataFieldParentID="ParentID" DataTextField="Text" ShowNodeLines="true">
                    <DataBindings>
                        <telerik:RadSiteMapNodeBinding NavigateUrl="#"></telerik:RadSiteMapNodeBinding>
                    </DataBindings>
                </telerik:RadSiteMap>
            </li>
        </ul>
    </div>
    <asp:SqlDataSource runat="server" ID="SqlDataSource1" ConnectionString="<%$ ConnectionStrings:TelerikConnectionString %>"
        SelectCommand="SELECT * FROM [SiteMap]">
        <SelectParameters>
            <asp:Parameter DefaultValue="1" Name="ID" Type="Int32"></asp:Parameter>
        </SelectParameters>
    </asp:SqlDataSource>
    <asp:ObjectDataSource ID="ObjectDataSource1" runat="server" SelectMethod="GetSiteData"
        TypeName="Telerik.Web.Examples.SiteDataItem"></asp:ObjectDataSource>
    </form>
</body>
</html>

Support & Learning Resources

Find Assistance