<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default2.aspx.cs" Inherits="Default2" %>
<%@ 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">
        <asp:ScriptManager runat="server" ID="ScriptManager1">
        </asp:ScriptManager>
    <div>
        
        <telerik:RadGrid runat="server" ID="RadGrid1" AllowPaging="True" 
            AllowSorting="True" AutoGenerateDeleteColumn="True" 
            AutoGenerateEditColumn="true" DataSourceID="LinqDataSource1" GridLines="None"
            AllowAutomaticDeletes="true" AllowAutomaticInserts="true" AllowAutomaticUpdates="true"
            Skin="WebBlue" AutoGenerateColumns="False" >
            <MasterTableView AutoGenerateColumns="False" DataSourceID="LinqDataSource1" 
                CommandItemDisplay="Top" DataKeyNames="CustomerID">
            <Columns>
                <telerik:GridBoundColumn DataField="CustomerID" HeaderText="CustomerID" 
                    ReadOnly="False" SortExpression="CustomerID" UniqueName="CustomerID">
                </telerik:GridBoundColumn>
                <telerik:GridBoundColumn DataField="CompanyName" HeaderText="CompanyName" 
                    ReadOnly="False" SortExpression="CompanyName" UniqueName="CompanyName">
                </telerik:GridBoundColumn>
                <telerik:GridBoundColumn DataField="ContactName" HeaderText="ContactName" 
                    ReadOnly="False" SortExpression="ContactName" UniqueName="ContactName">
                </telerik:GridBoundColumn>
            </Columns>           
        </MasterTableView>
        <ClientSettings EnablePostBackOnRowClick="true">
            <Selecting AllowRowSelect="true" />
        </ClientSettings>
    </telerik:RadGrid>
    
    <telerik:RadGrid runat="server" ID="RadGrid2" AllowPaging="True" 
            AllowSorting="True" AutoGenerateDeleteColumn="True" 
            AutoGenerateEditColumn="true" DataSourceID="LinqDataSource2" GridLines="None"
            AllowAutomaticDeletes="true" AllowAutomaticInserts="true" AllowAutomaticUpdates="true"
            Skin="WebBlue" AutoGenerateColumns="False">
        <MasterTableView DataKeyNames="OrderID">
            <Columns>
                <telerik:GridBoundColumn DataField="OrderID" HeaderText="OrderID" 
                    ReadOnly="True" SortExpression="OrderID" UniqueName="OrderID">
                </telerik:GridBoundColumn>
                <telerik:GridBoundColumn DataField="CustomerID" HeaderText="CustomerID" 
                    ReadOnly="False" SortExpression="CustomerID" UniqueName="CustomerID">
                </telerik:GridBoundColumn>
                <telerik:GridBoundColumn DataField="ShipName" HeaderText="ShipName" 
                    ReadOnly="False" SortExpression="ShipName" UniqueName="ShipName">
                </telerik:GridBoundColumn>
            </Columns>
        </MasterTableView>
    </telerik:RadGrid>
    
    <asp:LinqDataSource ID="LinqDataSource1" runat="server" 
        ContextTypeName="DataClassesDataContext" 
        TableName="Customers"  
        EnableUpdate="true" EnableDelete="True" EnableInsert="True">        
    </asp:LinqDataSource>  
    
    <asp:LinqDataSource ID="LinqDataSource2" runat="server" 
        ContextTypeName="DataClassesDataContext" 
        TableName="Orders"  
        EnableUpdate="true" EnableDelete="True" EnableInsert="True"
        Where="CustomerID == @CustomerID">  
        <WhereParameters>
            <asp:ControlParameter ControlID="RadGrid1" Name="CustomerID"  
                PropertyName="SelectedValues['CustomerID']" Type="String" DefaultValue="ALFKI"/>  
        </WhereParameters>      
    </asp:LinqDataSource>  
    
    <telerik:RadAjaxManager runat="server" ID="RadAjaxManager1">
        <AjaxSettings>
            <telerik:AjaxSetting AjaxControlID="RadGrid1">
                <UpdatedControls>
                    <telerik:AjaxUpdatedControl ControlID="RadGrid2" />
                </UpdatedControls>
            </telerik:AjaxSetting>
        </AjaxSettings>
    </telerik:RadAjaxManager>
        
    </div>
    </form>
</body>
</html>
