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

Declarative DataSources

  • Politics
    • CNN
    • NBC
    • ABC
  • Sports
    • US Sports
      • Baseball
      • Football
      • BasketBall
    • European Sports
      • Soccer
      • Volleyball
  • Events
    • Oscar Awards
    • MTV Movie Awards
  • Demo Configurator

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

Some of the declarative data sources are inherently hierarchical. These include SiteMapDataSource and XmlDataSource. When data-bound to these types of data sources, RadPanelBar automatically creates the panel item 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 panelbar declaratively in design time. As with binding to a DataSet, DataPanel Itemle, or DataView, you can use the ID-ParentID relation to establish a hierarchy among the panel items.

RadPanelBar supports binding to an ObjectDataSource as well. In addition to the standard Panel Item 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, RadPanelBar can create a hierarchy of Panel Items.

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

  • DefaultCS.aspx
  • DefaultCS.aspx.cs
  • panelbar.xml
<%@ Page Language="c#" CodeFile="DefaultCS.aspx.cs" AutoEventWireup="true" Inherits="PanelBar.Examples.PopulatingWithData.DeclarativeDataSources.DefaultCS" %>

<%@ Register TagPrefix="telerik" Namespace="Telerik.Web.UI" Assembly="Telerik.Web.UI" %>
<%@ Register TagPrefix="qsf" Namespace="Telerik.QuickStart" %>

<!DOCTYPE html>
<html xmlns='http://www.w3.org/1999/xhtml'>
<head runat="server">
    <title>Telerik ASP.NET Example</title>
</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:RadPanelBar RenderMode="Lightweight" ID="RadPanelBar1" runat="server" Height="300" Width="100%" ExpandMode="FullExpandedItem"
            DataSourceID="SqlDataSource1" DataFieldID="id" DataFieldParentID="ParentId" DataTextField="Text">
            <DataBindings>
                <telerik:RadPanelItemBinding Depth="0" Expanded="true" />
            </DataBindings>
        </telerik:RadPanelBar>
    </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="panelbar.xml"></asp:XmlDataSource>

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

    <qsf:ConfiguratorPanel runat="server" ID="ConfigurationPanel1" Title="Demo Configurator">
        <Views>
            <qsf:View Title="Select a declarative datasource:">
                <asp:RadioButtonList ID="RadioButtonList1" runat="server" AutoPostBack="True" CssClass="checkbox-list-h"
                    OnSelectedIndexChanged="RadioButtonList1_SelectedIndexChanged">
                    <asp:ListItem Value="SiteMapDataSource1">SiteMapDataSource</asp:ListItem>
                    <asp:ListItem Value="SqlDataSource1" Selected="True">AccessDataSource</asp:ListItem>
                    <asp:ListItem Value="XmlDataSource1">XmlDataSource</asp:ListItem>
                    <asp:ListItem Value="ObjectDataSource1">ObjectDataSource</asp:ListItem>
                </asp:RadioButtonList>
            </qsf:View>
        </Views>

    </qsf:ConfiguratorPanel>
    </form>
</body>
</html>

Support & Learning Resources

Find Assistance