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

<%@ Register Assembly="RadGrid.Net2" Namespace="Telerik.WebControls" TagPrefix="rad" %>
<!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>
    <style type="text/css">
    
    
    
    </style>
</head>
<body>

<form id="form1" runat="server" style="margin:50;">

        <script>

            function GridCreated()
            {               
               var id = document.getElementById("controlID");
               if(id.value!="")
               { 
               alert(id.value);
                    try
                    {       
                    var row =  document.getElementById(id.value);
                    row.scrollIntoView(false);
                    }
                    catch(exception)
                    {
                    //
                    }
               }                                
            }
            
           
        </script>
        
        <input type="hidden" id="controlID" runat="server" />
        
          <rad:RadGrid ID="RadGrid1" Skin="WebBlue" DataSourceID="AccessDataSource1" runat="server" Width="95%" AutoGenerateColumns="False"
            PageSize="3" AllowSorting="True" GridLines="None" OnItemCommand="RadGrid1_ItemCommand" OnItemDataBound="RadGrid1_ItemDataBound">
            <PagerStyle Mode="NumericPages"></PagerStyle>
            <MasterTableView CommandItemDisplay="Top" TableLayout="Fixed"
             DataSourceID="AccessDataSource1" DataKeyNames="CustomerID" AllowMultiColumnSorting="True"
                Width="100%">
                
                <CommandItemTemplate>
                <asp:TextBox runat="server" ID="TextBox1">
                </asp:TextBox>
                <asp:Button runat="server" Text="Find" ID="Button1" OnClick="Button1_Click" />
                </CommandItemTemplate>
                
                <DetailTables>
                    <rad:GridTableView DataKeyNames="OrderID" DataSourceID="AccessDataSource2" Width="100%" runat="server" >
                        <ParentTableRelation>
                            <rad:GridRelationFields DetailKeyField="CustomerID" MasterKeyField="CustomerID" />
                        </ParentTableRelation>
                        <DetailTables>
                            <rad:GridTableView DataKeyNames="OrderID" DataSourceID="AccessDataSource3" Width="100%" runat="server">
                                <ParentTableRelation>
                                    <rad:GridRelationFields DetailKeyField="OrderID" MasterKeyField="OrderID" />
                                </ParentTableRelation>
                                <Columns>
                                
                                <rad:GridEditCommandColumn>
                                </rad:GridEditCommandColumn>
                                
                                    <rad:GridBoundColumn SortExpression="UnitPrice" HeaderText="Unit Price" HeaderButtonType="TextButton"
                                        DataField="UnitPrice" UniqueName="UnitPrice">
                                    </rad:GridBoundColumn>
                                    <rad:GridBoundColumn SortExpression="Quantity" HeaderText="Quantity" HeaderButtonType="TextButton"
                                        DataField="Quantity" UniqueName="Quantity">
                                    </rad:GridBoundColumn>
                                    <rad:GridBoundColumn SortExpression="Discount" HeaderText="Discount" HeaderButtonType="TextButton"
                                        DataField="Discount" UniqueName="Discount">
                                    </rad:GridBoundColumn>
                                      <rad:GridBoundColumn DataField="TagID" DataType="System.Int32" HeaderText="TagID"
                        SortExpression="TagID" UniqueName="TagID">
                    </rad:GridBoundColumn>
                                </Columns>
                                <SortExpressions>
                                    <rad:GridSortExpression FieldName="Quantity" SortOrder="Descending"></rad:GridSortExpression>
                                </SortExpressions>
                                <RowIndicatorColumn Visible="False">
                                    <HeaderStyle Width="20px" />
                                </RowIndicatorColumn>
                                <ExpandCollapseColumn Resizable="False" Visible="False">
                                    <HeaderStyle Width="20px" />
                                </ExpandCollapseColumn>
                                </rad:GridTableView>
                        </DetailTables>
                        <Columns>
                            <rad:GridBoundColumn SortExpression="OrderID" HeaderText="OrderID" HeaderButtonType="TextButton"
                                DataField="OrderID" UniqueName="OrderID">
                            </rad:GridBoundColumn>
                            <rad:GridBoundColumn SortExpression="OrderDate" HeaderText="Date Ordered" HeaderButtonType="TextButton"
                                DataField="OrderDate" UniqueName="OrderDate">
                            </rad:GridBoundColumn>
                            <rad:GridBoundColumn SortExpression="EmployeeID" HeaderText="EmployeeID" HeaderButtonType="TextButton"
                                DataField="EmployeeID" UniqueName="EmployeeID">
                            </rad:GridBoundColumn>
                              <rad:GridBoundColumn DataField="TagID" DataType="System.Int32" HeaderText="TagID"
                        SortExpression="TagID" UniqueName="TagID">
                    </rad:GridBoundColumn>
                            
                            
                        </Columns>
                        <SortExpressions>
                            <rad:GridSortExpression FieldName="OrderDate"></rad:GridSortExpression>
                        </SortExpressions>
                        <RowIndicatorColumn Visible="False">
                            <HeaderStyle Width="20px" />
                        </RowIndicatorColumn>
                        <ExpandCollapseColumn Resizable="False">
                            <HeaderStyle Width="20px" />
                        </ExpandCollapseColumn>
                    </rad:GridTableView>
                    
                    
                </DetailTables>
                <Columns>
                    <rad:GridBoundColumn DataField="CustomerID" HeaderText="CustomerID" ReadOnly="True"
                        SortExpression="CustomerID" UniqueName="CustomerID">
                    </rad:GridBoundColumn>
                    <rad:GridBoundColumn DataField="CompanyName" HeaderText="CompanyName" SortExpression="CompanyName"
                        UniqueName="CompanyName">
                    </rad:GridBoundColumn>
                    <rad:GridBoundColumn DataField="ContactName" HeaderText="ContactName" SortExpression="ContactName"
                        UniqueName="ContactName">
                    </rad:GridBoundColumn>
                    <rad:GridBoundColumn DataField="ContactTitle" HeaderText="ContactTitle" SortExpression="ContactTitle"
                        UniqueName="ContactTitle">
                    </rad:GridBoundColumn>
                    <rad:GridBoundColumn DataField="TagID" DataType="System.Int32" HeaderText="TagID"
                        SortExpression="TagID" UniqueName="TagID">
                    </rad:GridBoundColumn>
                </Columns>
                <SortExpressions>
                    <rad:GridSortExpression FieldName="CompanyName"></rad:GridSortExpression>
                </SortExpressions>
                <RowIndicatorColumn Visible="False">
                    <HeaderStyle Width="20px" />
                </RowIndicatorColumn>
                <ExpandCollapseColumn Resizable="False">
                    <HeaderStyle Width="20px" />
                </ExpandCollapseColumn>
            </MasterTableView>
            
            <ClientSettings AllowExpandCollapse="True">
            <ClientEvents OnGridCreated="GridCreated" />            
                <Selecting AllowRowSelect="True" />
                <Scrolling AllowScroll="True" UseStaticHeaders="True" SaveScrollPosition="false" />
            </ClientSettings>
            
        </rad:RadGrid>
<asp:AccessDataSource ID="AccessDataSource1" DataFile="~/App_Data/Nwind.mdb"
SelectCommand="SELECT [CustomerID], [CompanyName], [ContactName], [ContactTitle], [TagID] 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>
<asp:AccessDataSource ID="AccessDataSource3" DataFile="~/App_Data/Nwind.mdb"
SelectCommand="SELECT * FROM [Order Details] where OrderID = ?" runat="server">
            <SelectParameters>
                <asp:SessionParameter Name="OrderID" SessionField="OrderID" Type="Int32" />
            </SelectParameters>
        </asp:AccessDataSource>
       
        
    </form>
</body>
</html>
