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

Declarative Data Sources

ObjectDataSource

  • UI for ASP.NET Ajax
    • Grid
    • Scheduler
    • Editor
  • UI for Silverlight
    • Grid
    • Menu
    • Editor

SiteMapDataSource

  • Products
    • UI for ASP.NET AJAX
    • UI for WinForms
    • UI for WPF
    • UI for Silverlight
    • Reporting
    • Data Access
    • Sitefinity ASP.NET CMS
    • Test Studio
  • Consulting
    • On-site Training
    • Consulting Express
    • Open Classes Training
    • Online Training
    • Project Consulting
    • Telerik Webinars
  • Purchase
    • Buy Now
    • Renewals & Upgrades
    • License Agreement
    • FAQ
    • Purchase Orders
    • Contact Sales
  • Support
    • Support by Product
    • Documentation
    • Demos
    • Knowledge Base
    • Telerik Trainer
    • Videos
    • Skins
  • Community
    • Forums
    • Blogs
    • Events
    • Code Library
    • Learning Resources
    • Announcements
    • Free Products
  • Company
    • About Telerik
    • Press Center
    • Careers
    • Contact Us

XmlDataSource

  • File
    • New
    • Open
    • Save
    • Save As
    • Print Preview
    • Print
    • Close
  • Edit
    • Undo
    • Cut
    • Copy
    • Paste
    • Clipboard...
  • Insert
    • Break...
    • Page Numbers...
    • Date and Time...
    • Field...
    • Symbol...
    • Comment
    • Picture
    • Diagram
    • Text Box
    • Hyperlink
  • Format
    • Font
    • Paragraph...
    • Bullets and Numbering...
    • Borders and Shading...
    • Columns
    • Tabs
    • Change Case
    • Background
    • Theme
    • Frames
    • Autoformat
  • View
    • Normal
    • Web Layout
    • Print Layout
    • Task Pane
  • Tools
    • Spelling And Grammar...
    • Research...
    • Language
    • Word Count...
    • Track Changes
    • Compare And Merge Documents..

EntityDataSource

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

Some of the declarative data sources are inherently hierarchical. That includes SiteMapDataSource and XmlDataSource. When data-bound to these types of data sources, RadNavigation automatically creates the Navigation node hierarchy. There is no need to use the DataFieldID and DataFieldParentID properties.

The AccessDataSource is a table-based DataSource component. It can be used to bind the RadNavigation declaratively at design time. As with binding to a DataSet, DataTable, or DataView, you can use the ID-ParentID relation to establish a hierarchy among Navigation Nodes.

RadNavigation supports binding to an ObjectDataSource as well. In addition to the standard Navigation Node properties (Text, Value, Navigate Url, etc.) that can be bound to the underlying business objects, the DataFieldID and DataFieldParentID properties can be specified, too. In this way, RadNavigation can create a hierarchy of its Nodes.

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

For more details on the aforementioned algorithm, you can read the following article - Binding to object-based data sources .

  • DefaultCS.aspx
  • DefaultCS.aspx.cs
  • styles.css
  • Navigation.xml
<%@ Page Title="" Language="C#"  AutoEventWireup="true" CodeFile="DefaultCS.aspx.cs" Inherits="Navigation_Data_Binding_Server_side_Binding_Declarative_Data_Sources_DefaultCS" %>

<!DOCTYPE html>
<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-container size-medium">
        <h2>ObjectDataSource</h2>
        <telerik:RadNavigation runat="server" ID="RadNavigation4" DataSourceID="ObjectDataSource1" DataTextField="Text"
            DataFieldID="ID" DataFieldParentID="ParentID" Style="z-index: 7" EnableRoundedCorners="true"
            EnableShadows="true" EnableTextHTMLEncoding="true">
        </telerik:RadNavigation>
    </div>

    <div class="demo-container size-medium">
        <h2>SiteMapDataSource</h2>
        <telerik:RadNavigation runat="server" ID="RadNavigation2" DataSourceID="SiteMapDataSource1" Style="z-index: 6"
            EnableRoundedCorners="true" EnableShadows="true" EnableTextHTMLEncoding="true">
        </telerik:RadNavigation>
    </div>

    <div class="demo-container size-medium">
        <h2>XmlDataSource</h2>
        <telerik:RadNavigation runat="server" ID="RadNavigation3" DataSourceID="XmlDataSource1" DataTextField="Text"
            Style="z-index: 4" EnableRoundedCorners="true" EnableShadows="true" EnableTextHTMLEncoding="true">
        </telerik:RadNavigation>
    </div>

    <div class="demo-container size-medium">
        <h2>EntityDataSource</h2>
        <telerik:RadNavigation runat="server" ID="RadNavigation5" DataSourceID="EntityDataSource1" DataTextField="Text"
            DataFieldID="id" DataFieldParentID="parentId"
            Style="z-index: 3" EnableRoundedCorners="true" EnableShadows="true" EnableTextHTMLEncoding="true">
        </telerik:RadNavigation>
    </div>

    <asp:SiteMapDataSource runat="server" ID="SiteMapDataSource1" ShowStartingNode="false"></asp:SiteMapDataSource>

    <asp:SqlDataSource runat="server" ID="SqlDataSource1" ConnectionString="<%$ ConnectionStrings:TelerikConnectionString %>"
        ProviderName="System.Data.SqlClient" SelectCommand="SELECT id, Text, parentId  from Links"></asp:SqlDataSource>

    <asp:XmlDataSource runat="server" ID="XmlDataSource1" DataFile="Navigation.xml"
        XPath="/Navigation/Item"></asp:XmlDataSource>

    <asp:ObjectDataSource ID="ObjectDataSource1" runat="server" SelectMethod="GetSiteData"
        TypeName="Telerik.Web.Examples.SiteDataItem"></asp:ObjectDataSource>

    <asp:EntityDataSource runat="server" ID="EntityDataSource1" ConnectionString="name=TelerikReadWriteEntities"
        DefaultContainerName="TelerikReadWriteEntities" EntitySetName="Links">
    </asp:EntityDataSource>


    </form>
</body>
</html>

Support & Learning Resources

Find Assistance