Telerik is a leading vendor of ASP.NET AJAX, ASP.NET MVC, Silverlight, WinForms and WPF controls and components, as well as .NET Reporting, .NET ORM , .NET CMS, Code Analysis, Mocking, Team Productivity and Automated Testing Tools. Building on its expertise in interface development and Microsoft technologies, Telerik helps customers build applications with unparalleled richness, responsiveness and interactivity. Telerik products help thousands of companies to be more productive and deliver reliable applications under budget and on time.
Version Q1 2012 released 04/11/2012
select

TabStrip / Hierarchical Data Binding


  • RadTabStrip fully supports binding to a wide range of datasources:

    • DataSet, DataTable, DataView
    • ASP 2.0 DataSource types including
      • Hierarchical DataSource components
      • Table-based DataSource components
      • ObjectDataSource
    • Any object that implements the IEnumerable interface   

    Below are the properties and methods related to data binding:

    DataSource - Set to an instance of your data source. This is mandatory when binding the RadTabStrip at runtime
    DataSourceID - Set to the ID of your data source. This is mandatory when binding the RadTabStrip declaratively
    DataMember - If the data source is a DataSet and DataMember is set, then the RadTabStrip is bound to the DataTable with the respective name in the DataSet. If DataMember is not set, the RadTabStrip is bound to the first DataTable in the DataSet
    DataFieldID - This is the field name from the data source used to uniquely identify each row. This field is required when binding to hierarchical data
    DataFieldParentID - This is the field name from the data source used to identify the row for the parent tab. This field is required when binding to hierarchical data
    DataTextField - This is the field name from the data source that populates each tab's Text property during binding
    DataValueField - This is the field name from the data source that populates each tab's Value property during binding
    DataNavigateUrlField - This is the field name from the data source that populates each tab's NavigateUrlField property during binding
    DataBind - Call this method after you have set the aforementioned properties when binding at runtime. This method is mandatory for binding at runtime
    MaxDataBindDepth - This property is used to determine the binding depth. If for example you want to bind only the first two levels of the tabstrip, you should set this property to 2. The default value of the MaxDataBindDepth property is -1, which means that all tabs will be bound. Marking the tabstrip instance with MaxDataBindDepth="0" will NOT bind any tabs.
    AppendDataBoundItems - If you bind the tabstrip using the DataBind method, all tabs are automatically cleared. Setting AppendDataBoundItems to True preserves the tabs that are already present in the tabstrip. This lets you bind RadTabStrip to multiple data sources or use both unbound and bound modes.

    If the data source contains fields that map to other properties of tabs or to custom attributes, use the TabDataBound event to set those values:

    [C#]
    protected void RadTabStrip1.TabDataBound(object sender,
    Telerik.Web.UI.RadTabStripEventArgs e)
    {
    e.Tab.ToolTip ="Read more about " +
    (string) DataBinder.Eval(e.Tab.DataItem, "Text");
    }


    [VB]
    Protected Sub RadTabStrip1_TabDataBound(ByVal sender As Object, _
    ByVal e As Telerik.Web.UI.RadTabStripEventArgs) Handles RadTabStrip1.TabDataBound
    e.Tab.ToolTip = "Read more about " + _
    CStr(DataBinder.Eval(e.Tab.DataItem, "Text"))
    End Sub

Source Code

C# VB.NET
Show code in new window Demo isolation steps
  • <%@ Page AutoEventWireup="true" CodeFile="DefaultCS.aspx.cs" Inherits="Telerik.Web.Examples.TabStrip.PopulatingWithData.HierarchicalDataBinding.DefaultCS"
        Language="c#" %>

    <%@ Register TagPrefix="qsf" Namespace="Telerik.QuickStart" %>
    <%@ Register TagPrefix="qsf" TagName="Header" Src="~/Common/Header.ascx" %>
    <%@ Register TagPrefix="qsf" TagName="HeadTag" Src="~/Common/HeadTag.ascx" %>
    <%@ Register TagPrefix="qsf" TagName="Footer" Src="~/Common/Footer.ascx" %>
    <%@ 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">
        <qsf:HeadTag runat="server" ID="Headtag1"></qsf:HeadTag>
    </head>
    <body class="BODY">
        <form runat="server" id="mainForm" method="post">
            <telerik:RadScriptManager runat="server" ID="ScriptManager1" />
            <qsf:Header runat="server" ID="Header1" NavigationLanguage="C#"></qsf:Header>
            <qsf:ConfiguratorPanel runat="server" ID="ConfigurationPanel1" Title="Select a datasource" Expanded="true">                        
                            <asp:RadioButtonList AutoPostBack="true" ID="RadioButtonList1" runat="server" OnSelectedIndexChanged="RadioButtonList1_SelectedIndexChanged">
                                <asp:ListItem Value="DataSet" Selected="True">DataSet</asp:ListItem>
                     <asp:ListItem Value="IEnumerable">IEnumerable</asp:ListItem>
                            </asp:RadioButtonList>
            </qsf:ConfiguratorPanel>                
            <telerik:RadTabStrip runat="server" ID="RadTabStrip1"
             SelectedIndex="0" MaxDataBindDepth="3"></telerik:RadTabStrip>    
            <qsf:Footer runat="server" ID="Footer1"></qsf:Footer>
        </form>
    </body>
    </html>

Get more than expected!

Take your time to truly experience the power of RadControls for ASP.NET AJAX with a free 60-day trial backed up by Telerik’s unlimited dedicated support.

Download your RadControls for ASP.NET AJAX trial and jumpstart your development with the available Getting Started resources.

If you have any questions, do not hesitate to contact us at sales@telerik.com.

Copyright 2002-2012 © Telerik. All right reserved
Telerik Inc, 201 Jones Rd, Waltham, MA 02451