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

<%@ Register Assembly="RadTabStrip.Net2" Namespace="Telerik.WebControls" TagPrefix="radTS" %>

<%@ Register Assembly="RadGrid.Net2" Namespace="Telerik.WebControls" TagPrefix="radG" %>

<%@ Register Assembly="RadCalendar.Net2" Namespace="Telerik.WebControls" TagPrefix="radCln" %>
<!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>Untitled Page</title>

    <script type="text/javascript">
       
    function checkChildren(id)
    {
    var masterCheckBox = document.getElementById(id);
    var checkBoxes = document.getElementsByTagName("input");
    
        for (var i=0; i< checkBoxes.length; i++)
        {
        var currentCheckBox = checkBoxes[i];    
        var masterId = masterCheckBox.id.substring(19, 20);
        var detailId = currentCheckBox.id.substring(19, 20);
                        
        if( masterId == (detailId - 2) )
        {        
        currentCheckBox.checked = masterCheckBox.checked;
        }
        }
    
  
    }
      
    </script>

    <style type="text/css">      

    
       
    </style>
</head>
<body>
    <form id="form1" runat="server">       
    
     <radG:RadGrid ID="RadGrid1" Skin="WebBlue" DataSourceID="AccessDataSource1" runat="server" Width="95%" AutoGenerateColumns="False"
            PageSize="3" AllowSorting="True" AllowMultiRowSelection="False" AllowPaging="True" GridLines="None" OnPreRender="RadGrid1_PreRender">
            <PagerStyle Mode="NumericPages"></PagerStyle>
            <ClientSettings AllowExpandCollapse="True">
            </ClientSettings>
            <MasterTableView HierarchyDefaultExpanded="true"
             DataSourceID="AccessDataSource1" DataKeyNames="CustomerID" AllowMultiColumnSorting="True"
                HierarchyLoadMode="Client" Width="100%">
                <DetailTables>
                    <radG:GridTableView DataKeyNames="OrderID" DataSourceID="AccessDataSource2" Width="100%" >
                        <ParentTableRelation>
                            <radG:GridRelationFields DetailKeyField="CustomerID" MasterKeyField="CustomerID" />
                        </ParentTableRelation>
                        
                        <Columns>
                        
                    <radG:GridTemplateColumn UniqueName="Template2">
                    <ItemTemplate>
                    <asp:CheckBox runat="server" ID="CheckBox2" />
                    </ItemTemplate>
                    </radG:GridTemplateColumn>                       
                        
                            <radG:GridBoundColumn SortExpression="OrderID" HeaderText="OrderID" HeaderButtonType="TextButton"
                                DataField="OrderID">
                            </radG:GridBoundColumn>
                            <radG:GridBoundColumn SortExpression="OrderDate" HeaderText="Date Ordered" HeaderButtonType="TextButton"
                                DataField="OrderDate">
                            </radG:GridBoundColumn>
                            <radG:GridBoundColumn SortExpression="EmployeeID" HeaderText="EmployeeID" HeaderButtonType="TextButton"
                                DataField="EmployeeID">
                            </radG:GridBoundColumn>
                        </Columns>
                        <SortExpressions>
                            <radG:GridSortExpression FieldName="OrderDate"></radG:GridSortExpression>
                        </SortExpressions>
                    </radG:GridTableView>
                </DetailTables>
                <Columns>
                
                    <radG:GridTemplateColumn UniqueName="Template1">
                    <ItemTemplate>
                    <asp:CheckBox runat="server" ID="CheckBox1" />
                    </ItemTemplate>
                    </radG:GridTemplateColumn>
                
                    <radG:GridBoundColumn SortExpression="CustomerID" HeaderText="CustomerID" HeaderButtonType="TextButton"
                        DataField="CustomerID">
                    </radG:GridBoundColumn>
                    <radG:GridBoundColumn SortExpression="ContactName" HeaderText="Contact Name" HeaderButtonType="TextButton"
                        DataField="ContactName">
                    </radG:GridBoundColumn>
                    <radG:GridBoundColumn SortExpression="CompanyName" HeaderText="Company" HeaderButtonType="TextButton"
                        DataField="CompanyName">
                    </radG:GridBoundColumn>
                </Columns>
                <SortExpressions>
                    <radG:GridSortExpression FieldName="CompanyName"></radG:GridSortExpression>
                </SortExpressions>
            </MasterTableView>
        </radG:RadGrid>
<asp:AccessDataSource ID="AccessDataSource1" DataFile="~/App_Data/Nwind.mdb"
SelectCommand="SELECT * FROM Customers" runat="server"></asp:AccessDataSource>
<asp:AccessDataSource ID="AccessDataSource2" DataFile="~/App_Data/Nwind.mdb"
SelectCommand="SELECT * FROM Orders Where CustomerID = ?" runat="server">
            <SelectParameters>
                <asp:SessionParameter Name="CustomerID" SessionField="CustomerID" Type="string" />
            </SelectParameters>
        </asp:AccessDataSource>


        
    </form>
</body>
</html>
