<%@ 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.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title>Untitled Page</title>
</head>
<body>
    <form id="form1" runat="server">
        <asp:ScriptManager ID="ScriptManager1" runat="server" />
        <div>
            <asp:ObjectDataSource ID="ObjectDataSource1" runat="server" SelectMethod="GetEmployeeInfo"
                TypeName="DataAccess"></asp:ObjectDataSource>
            <asp:ObjectDataSource ID="ObjectDataSource2" runat="server" SelectMethod="GetTerritory"
                TypeName="DataAccess">
                <SelectParameters>
                    <asp:SessionParameter DefaultValue="1" Name="EmployeeID" SessionField="EmployeeID"
                        Type="Int32" />
                </SelectParameters>
            </asp:ObjectDataSource>
            <telerik:RadAjaxManager ID="RadAjaxManager1" runat="server">
                <AjaxSettings>
                    <telerik:AjaxSetting AjaxControlID="RadGrid1">
                        <UpdatedControls>
                            <telerik:AjaxUpdatedControl ControlID="RadGrid1" />
                        </UpdatedControls>
                    </telerik:AjaxSetting>
                </AjaxSettings>
            </telerik:RadAjaxManager>
        </div>
        <telerik:RadGrid ID="RadGrid1" runat="server" DataSourceID="ObjectDataSource1" GridLines="None"
            OnItemCreated="RadGrid1_ItemCreated" OnItemDataBound="RadGrid1_ItemDataBound"
            OnDetailTableDataBind="RadGrid1_DetailTableDataBind">
            <HeaderContextMenu>
                <CollapseAnimation Duration="200" Type="OutQuint" />
            </HeaderContextMenu>
            <MasterTableView AllowFilteringByColumn="True" DataKeyNames="EmployeeID" AutoGenerateColumns="False"
                DataSourceID="ObjectDataSource1">
                <ParentTableRelation>
                    <telerik:GridRelationFields MasterKeyField="EmployeeID" DetailKeyField="EmployeeID" />
                </ParentTableRelation>
                <DetailTables>
                    <telerik:GridTableView AutoGenerateColumns="false" DataSourceID="ObjectDataSource2"
                        Name="TerritoryTable" DataKeyNames="EmployeeID">
                        <Columns>
                            <telerik:GridEditCommandColumn>
                            </telerik:GridEditCommandColumn>
                            <telerik:GridBoundColumn UniqueName="EmployeeID" HeaderText="Employee ID" DataField="EmployeeID">
                            </telerik:GridBoundColumn>
                            <%--<telerik:GridBoundColumn UniqueName="TerritoryID" DataField="TerritoryID" HeaderText="Territory ID">
                            </telerik:GridBoundColumn>--%>
                            <telerik:GridTemplateColumn DataField="TerritoryID" UniqueName="Territory" HeaderText="Territory">
                                <ItemTemplate>
                                    <asp:Label ID="territoryLabel" runat="server" Text='<%#Eval("TerritoryID") %>'></asp:Label>
                                </ItemTemplate>
                                <EditItemTemplate>
                                    <telerik:RadComboBox ID="territoryCombo" SelectedValue='<%# Bind("TerritoryID")%>'
                                        DataSourceID="ObjectDataSource2" DataTextField="TerritoryID" DataValueField="TerritoryID"
                                        runat="server">
                                    </telerik:RadComboBox>
                                </EditItemTemplate>
                            </telerik:GridTemplateColumn>
                        </Columns>
                    </telerik:GridTableView>
                </DetailTables>
                <CommandItemTemplate>
                </CommandItemTemplate>
                <Columns>
                    <telerik:GridEditCommandColumn>
                    </telerik:GridEditCommandColumn>
                    <telerik:GridBoundColumn DataField="EmployeeID" DataType="System.Int32" HeaderText="EmployeeID"
                        SortExpression="EmployeeID" UniqueName="EmployeeID">
                    </telerik:GridBoundColumn>
                    <telerik:GridBoundColumn DataField="FirstName" HeaderText="FirstName" SortExpression="FirstName"
                        UniqueName="FirstName">
                    </telerik:GridBoundColumn>
                    <telerik:GridBoundColumn DataField="LastName" HeaderText="LastName" SortExpression="LastName"
                        UniqueName="LastName">
                    </telerik:GridBoundColumn>
                    <telerik:GridTemplateColumn HeaderText="LastName" DataField="LastName" AllowFiltering="true">
                        <ItemTemplate>
                            <asp:TextBox ID="LastNameBox" runat="server" Text='<%#Bind("LastName") %>'></asp:TextBox>
                        </ItemTemplate>
                    </telerik:GridTemplateColumn>
                </Columns>
            </MasterTableView>
            <ClientSettings AllowColumnsReorder="true">
            </ClientSettings>
            <FilterMenu>
                <CollapseAnimation Duration="200" Type="OutQuint" />
            </FilterMenu>
        </telerik:RadGrid>
    </form>
</body>
</html>
