<%@ 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.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>
    <style type="text/css">
        
    </style>
</head>
<body>
    <form id="form1" runat="server">
    <asp:ScriptManager ID="ScriptManager1" runat="server">
    </asp:ScriptManager>
    <telerik:RadAjaxManager ID="RadAjaxManager1" runat="server" DefaultLoadingPanelID="RadAjaxLoadingPanel1">
        <AjaxSettings>
            <telerik:AjaxSetting AjaxControlID="RadGrid1">
                <UpdatedControls>
                    <telerik:AjaxUpdatedControl ControlID="RadGrid1" LoadingPanelID="RadAjaxLoadingPanel1" />
                </UpdatedControls>
            </telerik:AjaxSetting>
        </AjaxSettings>
    </telerik:RadAjaxManager>
    <telerik:RadAjaxLoadingPanel ID="RadAjaxLoadingPanel1" runat="server" Skin="Outlook">
    </telerik:RadAjaxLoadingPanel>
    <telerik:RadScriptBlock ID="ScriptBlock1" runat="server">
        <script type="text/javascript">
            
        </script>
    </telerik:RadScriptBlock>
    <telerik:RadGrid ID="RadGrid1" runat="server" DataSourceID="SqlDataSource1" GridLines="None"
        AllowFilteringByColumn="True" Skin="Default" CellSpacing="0" AllowMultiRowEdit="true"
        AllowMultiRowSelection="true">
        <MasterTableView CommandItemDisplay="Top" AutoGenerateColumns="False" AllowFilteringByColumn="true"
            AllowMultiColumnSorting="true" AllowAutomaticDeletes="true" AllowAutomaticInserts="true"
            AllowAutomaticUpdates="true" AllowSorting="true" AllowPaging="true" DataKeyNames="ProductID"
            DataSourceID="SqlDataSource1" EditMode="InPlace">
            <CommandItemSettings ExportToPdfText="Export to PDF"></CommandItemSettings>
            <Columns>
                <telerik:GridClientSelectColumn>
                </telerik:GridClientSelectColumn>
                <telerik:GridEditCommandColumn ButtonType="ImageButton">
                </telerik:GridEditCommandColumn>
                <telerik:GridBoundColumn DataField="ProductID" DataType="System.Int32" HeaderText="ProductID"
                    ReadOnly="True" SortExpression="ProductID" UniqueName="ProductID">
                </telerik:GridBoundColumn>
                <telerik:GridBoundColumn DataField="ProductName" HeaderText="ProductName" SortExpression="ProductName"
                    UniqueName="ProductName">
                </telerik:GridBoundColumn>
                <telerik:GridTemplateColumn HeaderText="Supplier" DataField="SupplierID" UniqueName="Supplier">
                    <ItemTemplate>
                        <asp:Label ID="lblSupplier" runat="server" Text='<%#Eval("CompanyName") %>'></asp:Label>
                    </ItemTemplate>
                    <EditItemTemplate>
                        <telerik:RadComboBox ID="rcmbSuppliers" DataTextField="CompanyName" DataValueField="SupplierID"
                            runat="server" SelectedValue='<%#Bind("SupplierID") %>'>
                        </telerik:RadComboBox>
                    </EditItemTemplate>
                </telerik:GridTemplateColumn>
                <telerik:GridDropDownColumn DataField="CategoryID" DataType="System.Int32" DataSourceID="SqlDataSource2"
                    ListTextField="CategoryName" ListValueField="CategoryID" HeaderText="CategoryID"
                    SortExpression="CategoryID" UniqueName="CategoryID">
                </telerik:GridDropDownColumn>
                <telerik:GridBoundColumn DataField="QuantityPerUnit" HeaderText="QuantityPerUnit"
                    SortExpression="QuantityPerUnit" UniqueName="QuantityPerUnit">
                </telerik:GridBoundColumn>
                <telerik:GridBoundColumn DataField="UnitPrice" DataType="System.Decimal" HeaderText="UnitPrice"
                    SortExpression="UnitPrice" UniqueName="UnitPrice">
                </telerik:GridBoundColumn>
                <telerik:GridBoundColumn DataField="UnitsInStock" DataType="System.Int16" HeaderText="UnitsInStock"
                    SortExpression="UnitsInStock" UniqueName="UnitsInStock">
                </telerik:GridBoundColumn>
                <telerik:GridBoundColumn DataField="ReorderLevel" DataType="System.Int16" HeaderText="ReorderLevel"
                    SortExpression="ReorderLevel" UniqueName="ReorderLevel">
                </telerik:GridBoundColumn>
                <telerik:GridCheckBoxColumn DataField="Discontinued" DataType="System.Boolean" HeaderText="Discontinued"
                    SortExpression="Discontinued" UniqueName="Discontinued">
                </telerik:GridCheckBoxColumn>
                <telerik:GridButtonColumn CommandName="Delete" ButtonType="ImageButton">
                </telerik:GridButtonColumn>
                <telerik:GridCalculatedColumn DataFormatString="{0:C}" DataType="System.Double" HeaderText="Extended Price"
                    UniqueName="ExtendedPrice" DataFields="UnitsInStock, UnitPrice" Expression="{0}*{1}"
                    FooterText="Total : " Aggregate="Sum">
                </telerik:GridCalculatedColumn>
            </Columns>
        </MasterTableView>
        <ClientSettings EnablePostBackOnRowClick="false">
            <Selecting AllowRowSelect="true" />
        </ClientSettings>
    </telerik:RadGrid>
    <asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:NorthwindConnectionString %>"
        SelectCommand="SELECT * FROM [Products] JOIN [SUPPLIERS] ON Products.SupplierID = Suppliers.SupplierID Where ProductID < -1"
        DeleteCommand="DELETE FROM [Products] WHERE [ProductID] = @ProductID" UpdateCommand="UPDATE [Products] SET [ProductName] = @ProductName, [SupplierID] = @SupplierID, [CategoryID] = @CategoryID, [QuantityPerUnit] = @QuantityPerUnit, [UnitPrice] = @UnitPrice, [UnitsInStock] = @UnitsInStock, [UnitsOnOrder] = @UnitsOnOrder, [ReorderLevel] = @ReorderLevel, [Discontinued] = @Discontinued WHERE [ProductID] = @ProductID"
        InsertCommand="INSERT INTO [Products] ([ProductName], [SupplierID], [CategoryID], [QuantityPerUnit], [UnitPrice], [UnitsInStock], [UnitsOnOrder], [ReorderLevel], [Discontinued]) VALUES (@ProductName, @SupplierID, @CategoryID, @QuantityPerUnit, @UnitPrice, @UnitsInStock, @UnitsOnOrder, @ReorderLevel, @Discontinued)">
        <DeleteParameters>
            <asp:Parameter Name="ProductID" Type="Int32" />
        </DeleteParameters>
        <UpdateParameters>
            <asp:Parameter Name="ProductName" Type="String" />
            <asp:Parameter Name="SupplierID" Type="Int32" />
            <asp:Parameter Name="CategoryID" Type="Int32" />
            <asp:Parameter Name="QuantityPerUnit" Type="String" />
            <asp:Parameter Name="UnitPrice" Type="Decimal" />
            <asp:Parameter Name="UnitsInStock" Type="Int16" />
            <asp:Parameter Name="UnitsOnOrder" Type="Int16" />
            <asp:Parameter Name="ReorderLevel" Type="Int16" />
            <asp:Parameter Name="Discontinued" Type="Boolean" />
            <asp:Parameter Name="ProductID" Type="Int32" />
        </UpdateParameters>
        <InsertParameters>
            <asp:Parameter Name="ProductName" Type="String" />
            <asp:Parameter Name="SupplierID" Type="Int32" />
            <asp:Parameter Name="CategoryID" Type="Int32" />
            <asp:Parameter Name="QuantityPerUnit" Type="String" />
            <asp:Parameter Name="UnitPrice" Type="Decimal" />
            <asp:Parameter Name="UnitsInStock" Type="Int16" />
            <asp:Parameter Name="UnitsOnOrder" Type="Int16" />
            <asp:Parameter Name="ReorderLevel" Type="Int16" />
            <asp:Parameter Name="Discontinued" Type="Boolean" />
        </InsertParameters>
    </asp:SqlDataSource>
    <asp:SqlDataSource ID="SqlDataSource2" ConnectionString="<%$ ConnectionStrings:NorthwindConnectionString %>"
        SelectCommand="SELECT * FROM [Categories]" runat="server"></asp:SqlDataSource>
    <asp:SqlDataSource ID="SqlDataSource3" ConnectionString="<%$ ConnectionStrings:NorthwindConnectionString %>"
        SelectCommand="SELECT * FROM [Suppliers]" runat="server"></asp:SqlDataSource>
    </form>
</body>
</html>
