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

<!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" />
    <telerik:RadAjaxManager runat="server" ID="RadAjaxManager1">
        <AjaxSettings>
            <telerik:AjaxSetting AjaxControlID="RadGrid2">
                <UpdatedControls>
                    <telerik:AjaxUpdatedControl ControlID="RadGrid2" />
                </UpdatedControls>
            </telerik:AjaxSetting>
        </AjaxSettings>
    </telerik:RadAjaxManager>
   
    <div class="demo-container">
        <telerik:RadGrid ID="RadGrid2" GridLines="None" AutoGenerateColumns="false" PageSize="20"
            AllowPaging="true" AllowSorting="true" runat="server" OnItemDataBound="RadGrid2_ItemDataBound"
            DataSourceID="SqlDataSource1" AllowAutomaticUpdates="true"
            ShowStatusBar="true" OnItemCreated="RadGrid2_ItemCreated">
            <MasterTableView ShowFooter="false" TableLayout="Fixed" EditMode="InPlace" CommandItemDisplay="TopAndBottom" CommandItemSettings-ShowAddNewRecordButton="false">
                <SortExpressions>
                    <telerik:GridSortExpression FieldName="TerritoryID" SortOrder="Ascending" />
                </SortExpressions>
                <Columns>
                    <telerik:GridTemplateColumn HeaderText="Supplier Name">
                        <ItemTemplate>
                            <%#DataBinder.Eval(Container.DataItem, "LastName")%>
                        </ItemTemplate>
                        <EditItemTemplate>
                            <telerik:RadDropDownTree runat="server" ID="RadDropDownTreeTest" DataTextField="LastName" DataFieldParentID="ReportsTo"
                                DataFieldID="EmployeeID" OnDataBound="RadDropDownTreeTest_DataBound"
                                DataValueField="EmployeeID" DataSourceID="SqlDataSource2" SelectedValue='<%#Bind("EmployeeID") %>'>
                                <DropDownSettings OpenDropDownOnLoad="true"  />
                            </telerik:RadDropDownTree>
                        </EditItemTemplate>
                    </telerik:GridTemplateColumn>
                    <telerik:GridBoundColumn DataField="TerritoryDescription" HeaderText="Territory" />
                    <telerik:GridBoundColumn DataField="TerritoryID" HeaderText="TerritoryID" />
                    <telerik:GridEditCommandColumn FooterText="EditCommand footer" UniqueName="EditCommandColumn"
                        HeaderText="Edit" HeaderStyle-Width="100px" UpdateText="Update">
                    </telerik:GridEditCommandColumn>
                </Columns>
            </MasterTableView>
        </telerik:RadGrid>
    </div>
    <asp:SqlDataSource ID="SqlDataSource2" runat="server" ConnectionString="<%$ ConnectionStrings:NorthwindConnectionString35 %>"
        SelectCommand="SELECT EmployeeID, ReportsTo, LastName FROM [Employees]"></asp:SqlDataSource>
 
    <asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:NorthwindConnectionString35 %>"
        SelectCommand="SELECT mediator.[EmployeeID], mediator.[TerritoryID], territories.[TerritoryDescription], empl.[LastName]
                            FROM [EmployeeTerritories] AS mediator
                            INNER JOIN Employees AS empl
                            ON mediator.EmployeeID = empl.EmployeeID
                            INNER JOIN Territories AS territories
                            ON mediator.TerritoryID = territories.TerritoryID"
        UpdateCommand="UPDATE EmployeeTerritories
                       SET  EmployeeTerritories.EmployeeID = @EmployeeID
                       WHERE EmployeeTerritories.TerritoryID = @TerritoryID">
 
        <UpdateParameters>
            <asp:Parameter Name="EmployeeID" Type="Int32" />
            <asp:Parameter Name="TerritoryID" Type="Int32" />
        </UpdateParameters>
    </asp:SqlDataSource>
    </form>
</body>
</html>
