<%@ Page Language="C#" AutoEventWireup="true"  CodeFile="Default.aspx.cs" Inherits="_Default" %>
<%@ Register Assembly="Telerik.Web.UI" Namespace="Telerik.Web.UI" TagPrefix="telerik" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
         <asp:ScriptManager runat="server" ID="ScriptManager1">
        </asp:ScriptManager>
        
        <telerik:RadGrid ID="RadGrid1" Skin="Sunset" ShowStatusBar="true" DataSourceID="SqlDataSource1"
            runat="server" AutoGenerateColumns="False" AllowSorting="True" AllowMultiRowSelection="False"
            AllowPaging="True" GridLines="None" OnItemDataBound="RadGrid1_ItemDataBound">
            <PagerStyle Mode="NumericPages"></PagerStyle>
            <MasterTableView Width="100%" DataSourceID="SqlDataSource1" DataKeyNames="CustomerID"
                AllowMultiColumnSorting="True">                
                <NestedViewTemplate>
                    <telerik:RadGrid runat="server" ID="RadGrid2" OnNeedDataSource="RadGrid2_NeedDataSource" Skin="Sunset"
                        AutoGenerateColumns="false">
                        <MasterTableView>                                                
                            <Columns>
                                <telerik:GridBoundColumn></telerik:GridBoundColumn>
                            </Columns>
                            <NestedViewTemplate>
                         
                                <asp:SqlDataSource ID="DetailsDataSource" 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>
                                <asp:DetailsView ID="DetailsView1" AllowPaging="true" GridLines="None" Width="100%" DataSourceID="DetailsDataSource"
                                    runat="server">
                                </asp:DetailsView>
                         
                            </NestedViewTemplate>
                        </MasterTableView>
                    </telerik:RadGrid>
                    
                    <telerik:RadGrid runat="server" ID="RadGrid3" OnNeedDataSource="RadGrid2_NeedDataSource" Skin="Sunset"
                        AutoGenerateColumns="false">
                        <MasterTableView>                                                
                            <Columns>
                                <telerik:GridBoundColumn></telerik:GridBoundColumn>
                            </Columns>
                            <NestedViewTemplate>
                         
                                <asp:SqlDataSource ID="DetailsDataSource" ConnectionString="<%$ ConnectionStrings:NorthwindConnectionString %>"
                                    ProviderName="System.Data.SqlClient" 
                                    SelectCommand="SELECT od.OrderID, od.ProductID, od.UnitPrice, od.Quantity, od.Discount FROM [Order Details] AS od INNER JOIN Orders AS o ON o.OrderID = od.OrderID WHERE (o.CustomerID = @CustomerID)"
                                    runat="server" >
                                    <SelectParameters>
                                       <asp:SessionParameter Name="CustomerID" SessionField="CustomerID" Type="string" />
                                    </SelectParameters>
                                </asp:SqlDataSource>
                                <asp:DetailsView ID="DetailsView1" AllowPaging="true" GridLines="None" Width="100%" DataSourceID="DetailsDataSource"
                                    runat="server">
                                </asp:DetailsView>
                         
                            </NestedViewTemplate>
                        </MasterTableView>
                    </telerik:RadGrid>
                   
                </NestedViewTemplate>
                <Columns>
                    <telerik:GridBoundColumn SortExpression="CustomerID" HeaderText="CustomerID" HeaderButtonType="TextButton"
                        DataField="CustomerID" UniqueName="CustomerID">
                    </telerik:GridBoundColumn>
                    <telerik:GridBoundColumn SortExpression="ContactName" HeaderText="Contact Name" HeaderButtonType="TextButton"
                        DataField="ContactName" UniqueName="ContactName">
                    </telerik:GridBoundColumn>
                    <telerik:GridBoundColumn SortExpression="CompanyName" HeaderText="Company" HeaderButtonType="TextButton"
                        DataField="CompanyName" UniqueName="CompanyName">
                    </telerik:GridBoundColumn>
                </Columns>
                <SortExpressions>
                    <telerik:GridSortExpression FieldName="CompanyName"></telerik:GridSortExpression>
                </SortExpressions>
            </MasterTableView>
        </telerik:RadGrid>
        
        <asp:SqlDataSource ID="SqlDataSource1" ConnectionString="<%$ ConnectionStrings:NorthwindConnectionString %>"
            ProviderName="System.Data.SqlClient" 
             SelectCommand="SELECT * FROM Customers" runat="server" 
             >
        </asp:SqlDataSource>
            
    </div>
    </form>
</body>
</html>
