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

Grid / NestedViewTemplate Relations

Drag a column header and drop it here to group by that column
 Contact nameContact titleCompany name
 Page 1 of 19, items 1 to 5 of 91.
Maria AndersSales RepresentativeAlfreds Futterkiste
Ana TrujilloOwnerAna Trujillo Emparedados y helados
Antonio MorenoOwnerAntonio Moreno Taquería
Thomas HardySales RepresentativeAround the Horn
Christina BerglundOrder AdministratorBerglunds snabbköp

  • The Nested view template declarative relations grid demo shows how to have a structure resembling a standard hierarchy, which can be greatly customized, while at the same time setting hierarchical relations between the master and detail levels and binding the detail level on demand.
    The example shows a list of customers. In the detail view for each customer additonal relevant details of his personal information are contained, along with a photograph.

Source Code

C# VB.NET
Show code in new window Demo isolation steps
  • <%@ Page Language="VB" CodeFile="defaultvb.aspx.vb" Inherits="Telerik.GridExamplesVBNET.Hierarchy.NestedViewTemplate.DefaultVB" %>

    <%@ Register TagPrefix="telerik" Namespace="Telerik.QuickStart" %>
    <%@ Register TagPrefix="telerik" TagName="Header" Src="~/Common/Header.ascx" %>
    <%@ Register TagPrefix="telerik" TagName="HeadTag" Src="~/Common/HeadTag.ascx" %>
    <%@ Register TagPrefix="telerik" TagName="Footer" Src="~/Common/Footer.ascx" %>
    <%@ Register TagPrefix="telerik" Namespace="Telerik.Charting" Assembly="Telerik.Web.UI" %>
    <%@ 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">
        <telerik:HeadTag runat="server" ID="Headtag2"></telerik:HeadTag>
        <!-- custom head section -->
        <style type="text/css">
            .viewWrap
            {
                padding: 15px;
                background: #2291b5 0 0 url(Img/bluegradient.gif) repeat-x;
            }
            .contactWrap
            {
                padding: 10px 15px 15px 15px;
                background: #fff;
                color: #333;
            }
            .contactWrap td
            {
                padding: 0 20px 0 0;
            }
            .contactWrap td td
            {
                padding: 3px 20px 3px 0;
            }
            .contactWrap img
            {
                border: 1px solid #05679d;
            }
        </style>
        <!-- end of custom head section -->
    </head>
    <body class="BODY">
        <form runat="server" id="mainForm" method="post">
        <telerik:Header runat="server" ID="Header1" NavigationLanguage="VB"></telerik:Header>
        <telerik:RadScriptManager runat="server" ID="ScriptManager1">
        </telerik:RadScriptManager>
        <!-- content start -->
        <telerik:RadAjaxManager ID="RadAjaxManager1" runat="server">
            <AjaxSettings>
                <telerik:AjaxSetting AjaxControlID="RadGrid1">
                    <UpdatedControls>
                        <telerik:AjaxUpdatedControl ControlID="RadGrid1" LoadingPanelID="RadAjaxLoadingPanel1" />
                    </UpdatedControls>
                </telerik:AjaxSetting>
            </AjaxSettings>
        </telerik:RadAjaxManager>
        <telerik:RadAjaxLoadingPanel ID="RadAjaxLoadingPanel1" runat="server" />
        
        <telerik:RadGrid ID="RadGrid1" DataSourceID="SqlDataSource1" runat="server" AutoGenerateColumns="False"
            AllowSorting="True" AllowPaging="True" PageSize="5" GridLines="None" ShowGroupPanel="True">
            <MasterTableView DataSourceID="SqlDataSource1" DataKeyNames="CustomerID" AllowMultiColumnSorting="True"
                GroupLoadMode="Server">
                <Columns>
                    <telerik:GridBoundColumn DataField="ContactName" HeaderText="Contact name" SortExpression="ContactName"
                        UniqueName="ContactName">
                    </telerik:GridBoundColumn>
                    <telerik:GridBoundColumn DataField="ContactTitle" HeaderText="Contact title" SortExpression="ContactTitle"
                        UniqueName="ContactTitle">
                    </telerik:GridBoundColumn>
                    <telerik:GridBoundColumn DataField="CompanyName" HeaderText="Company name" SortExpression="CompanyName"
                        UniqueName="CompanyName">
                    </telerik:GridBoundColumn>
                </Columns>
                <NestedViewSettings DataSourceID="SqlDataSource2">
                    <ParentTableRelation>
                        <telerik:GridRelationFields DetailKeyField="CustomerID" MasterKeyField="CustomerID" />
                    </ParentTableRelation>
                </NestedViewSettings>
                <NestedViewTemplate>
                    <asp:Panel ID="NestedViewPanel" runat="server" CssClass="viewWrap">
                        <div class="contactWrap">
                            <fieldset style="padding: 10px;">
                                <legend style="padding: 5px;"><b>Detail info for Customer:&nbsp; &nbsp;<%#Eval("ContactName") %></b>
                                </legend>
                                <table>
                                    <tbody>
                                        <tr>
                                            <td>
                                                <table>
                                                    <tbody>
                                                        <tr>
                                                            <td>
                                                                ContactTitle:
                                                            </td>
                                                            <td>
                                                                <asp:Label ID="cityLabel" Text='<%#Bind("ContactTitle") %>' runat="server"></asp:Label>
                                                            </td>
                                                        </tr>
                                                        <tr>
                                                            <td>
                                                                Address:
                                                            </td>
                                                            <td>
                                                                <asp:Label ID="Label2" Text='<%#Bind("Address") %>' runat="server"></asp:Label>
                                                            </td>
                                                        </tr>
                                                        <tr>
                                                            <td>
                                                                City:
                                                            </td>
                                                            <td>
                                                                <asp:Label ID="Label3" Text='<%#Bind("City") %>' runat="server"></asp:Label>
                                                            </td>
                                                        </tr>
                                                        <tr>
                                                            <td>
                                                                PostalCode:
                                                            </td>
                                                            <td>
                                                                <asp:Label ID="Label4" Text='<%#Bind("PostalCode") %>' runat="server"></asp:Label>
                                                            </td>
                                                        </tr>
                                                        <tr>
                                                            <td>
                                                                Country:
                                                            </td>
                                                            <td>
                                                                <asp:Label ID="Label5" Text='<%#Bind("Country") %>' runat="server"></asp:Label>
                                                            </td>
                                                        </tr>
                                                        <tr>
                                                            <td>
                                                                Phone:
                                                            </td>
                                                            <td>
                                                                <asp:Label ID="Label6" Text='<%#Bind("Phone") %>' runat="server"></asp:Label>
                                                            </td>
                                                        </tr>
                                                        <tr>
                                                            <td>
                                                                Fax:
                                                            </td>
                                                            <td>
                                                                <asp:Label ID="Label7" Text='<%#Bind("Fax") %>' runat="server"></asp:Label>
                                                            </td>
                                                        </tr>
                                                    </tbody>
                                                </table>
                                            </td>
                                            <td>
                                                <img src='<%# Page.ResolveUrl("~/Grid/Examples/Hierarchy/NestedViewTemplateDeclarativeRelations/Img/") + Eval("CustomerID") %>.jpg'
                                                    alt="Customer Image" />
                                            </td>
                                        </tr>
                                    </tbody>
                                </table>
                            </fieldset>
                        </div>
                    </asp:Panel>
                </NestedViewTemplate>
            </MasterTableView>
            <PagerStyle Mode="NumericPages"></PagerStyle>
            <ClientSettings AllowDragToGroup="true" />
        </telerik:RadGrid>
        <asp:SqlDataSource ID="SqlDataSource2" ConnectionString="<%$ ConnectionStrings:NorthwindConnectionString %>"
            SelectCommand="SELECT [CustomerID],[ContactName],[ContactTitle], [Address],[City],[PostalCode],[Country],[Phone],[Fax] FROM [Customers] where CustomerID=@CustomerID"
            runat="server">
            <SelectParameters>
                <asp:Parameter Name="CustomerID" />
            </SelectParameters>
        </asp:SqlDataSource>
        <asp:SqlDataSource ID="SqlDataSource1" ConnectionString="<%$ ConnectionStrings:NorthwindConnectionString %>"
            SelectCommand="SELECT [CustomerID], [CompanyName], [ContactName], [ContactTitle] FROM [Customers]"
            runat="server"></asp:SqlDataSource>
        <!-- content end -->
        <telerik:Footer runat="server" ID="Footer1"></telerik: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