<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>

<%@ 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 id="Head1" runat="server">
</head>
<body class="BODY">
    <form runat="server" id="mainForm" method="post">
    <telerik:RadScriptManager ID="RadScriptManager1" runat="server" />
    <telerik:RadGrid ID="RadGrid1" OnPreRender="RadGrid1_PreRender" DataSourceID="SqlDataSource1"
        runat="server" AutoGenerateColumns="False" PageSize="7" AllowPaging="True">
        <MasterTableView DataSourceID="SqlDataSource1" DataKeyNames="CustomerID" CommandItemDisplay="Top">
            <DetailTables>
                <telerik:GridTableView DataSourceID="SqlDataSource2" runat="server" CommandItemDisplay="Top">
                    <ParentTableRelation>
                        <telerik:GridRelationFields DetailKeyField="CustomerID" MasterKeyField="CustomerID" />
                    </ParentTableRelation>
                    <Columns>
                        <telerik:GridBoundColumn HeaderText="OrderID" DataField="OrderID" UniqueName="OrderID"
                            HeaderStyle-Width="200px">
                        </telerik:GridBoundColumn>
                        <telerik:GridBoundColumn HeaderText="Date Ordered" DataField="OrderDate" UniqueName="OrderDate"
                            DataFormatString="{0:D}" HeaderStyle-Width="300px">
                        </telerik:GridBoundColumn>
                        <telerik:GridBoundColumn HeaderText="Freight" DataField="Freight" UniqueName="Freight"
                            HeaderStyle-Width="400px">
                        </telerik:GridBoundColumn>
                    </Columns>
                </telerik:GridTableView>
            </DetailTables>
            <Columns>
                <telerik:GridBoundColumn HeaderText="CustomerID" DataField="CustomerID" UniqueName="CustomerID"
                    HeaderStyle-Width="400px">
                </telerik:GridBoundColumn>
                <telerik:GridBoundColumn HeaderText="Contact Name" DataField="ContactName" UniqueName="ContactName"
                    HeaderStyle-Width="300px">
                </telerik:GridBoundColumn>
                <telerik:GridBoundColumn HeaderText="Company" DataField="CompanyName" UniqueName="CompanyName"
                    HeaderStyle-Width="200px">
                </telerik:GridBoundColumn>
            </Columns>
        </MasterTableView>
        <ClientSettings Resizing-AllowColumnResize="true">
        </ClientSettings>
    </telerik:RadGrid>
    <asp:SqlDataSource ID="SqlDataSource1" ConnectionString="<%$ ConnectionStrings:NorthwindConnectionString %>"
        ProviderName="System.Data.SqlClient" SelectCommand="SELECT * FROM Customers"
        runat="server"></asp:SqlDataSource>
    <asp:SqlDataSource ID="SqlDataSource2" ConnectionString="<%$ ConnectionStrings:NorthwindConnectionString %>"
        ProviderName="System.Data.SqlClient" SelectCommand="SELECT * FROM Orders Where CustomerID = @CustomerID"
        runat="server">
        <SelectParameters>
            <asp:SessionParameter Name="CustomerID" SessionField="CustomerID" Type="string" />
        </SelectParameters>
    </asp:SqlDataSource>
    </form>
</body>
</html>
