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

<!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>
    <telerik:RadStyleSheetManager ID="RadStyleSheetManager1" runat="server" />
    <telerik:RadScriptBlock runat="server">

        <script type="text/javascript">
        </script>

    </telerik:RadScriptBlock>
</head>
<body>
    <form id="form1" runat="server">
    <telerik:RadScriptManager ID="RadScriptManager1" runat="server">
        <Scripts>
            <asp:ScriptReference Assembly="Telerik.Web.UI" Name="Telerik.Web.UI.Common.Core.js" />
            <asp:ScriptReference Assembly="Telerik.Web.UI" Name="Telerik.Web.UI.Common.jQuery.js" />
        </Scripts>
    </telerik:RadScriptManager>
    <telerik:RadAjaxManager ID="RadAjaxManager1" runat="server">
    </telerik:RadAjaxManager>
    <div>
        <telerik:RadInputManager ID="RadInputManager1" runat="server">
            <telerik:TextBoxSetting BehaviorID="TextBoxBehavior1" InitializeOnClient="false">
            </telerik:TextBoxSetting>
            <telerik:DateInputSetting BehaviorID="DateInputBehavior1" InitializeOnClient="false"
                Culture="en-US" DateFormat="MM/dd/yyyy">
            </telerik:DateInputSetting>
            <telerik:NumericTextBoxSetting BehaviorID="NumericBehavior1" InitializeOnClient="false"
                Type="Number" DecimalDigits="2">
            </telerik:NumericTextBoxSetting>
            <telerik:RegExpTextBoxSetting BehaviorID="RegExpBehavior1" InitializeOnClient="false"
                ErrorMessage="Invalid ShipPostalCode" InvalidCssClass="invalid" ValidationExpression="[\w\d-]{4,10}">
                <Validation IsRequired="true" />
            </telerik:RegExpTextBoxSetting>
        </telerik:RadInputManager>
        <telerik:RadGrid ID="RadGrid1" runat="server" DataSourceID="SessionDataSource1" AllowMultiRowEdit="true"
            GridLines="None" AllowPaging="True" OnItemCreated="RadGrid1_ItemCreated" AllowAutomaticUpdates="true"
            AllowAutomaticInserts="true" AllowAutomaticDeletes="true" AllowSorting="true">
            <MasterTableView EditMode="InPlace" AutoGenerateColumns="False" DataKeyNames="OrderID" DataSourceID="SessionDataSource1"
                CommandItemDisplay="Top">
                <PagerStyle Mode="NextPrevAndNumeric" />
                <Columns>
                    <telerik:GridEditCommandColumn ButtonType="ImageButton" />
                    <telerik:GridBoundColumn DataField="OrderID" DataType="System.Int32" HeaderText="OrderID"
                        ReadOnly="True" SortExpression="OrderID" UniqueName="OrderID">
                    </telerik:GridBoundColumn>
                    <telerik:GridBoundColumn DataField="OrderDate" DataType="System.DateTime" HeaderText="OrderDate"
                        SortExpression="OrderDate" UniqueName="OrderDate" DataFormatString="{0:D}">
                    </telerik:GridBoundColumn>
                    <telerik:GridBoundColumn DataField="Freight" DataType="System.Decimal" HeaderText="Freight"
                        SortExpression="Freight" UniqueName="Freight">
                    </telerik:GridBoundColumn>
                    <telerik:GridBoundColumn DataField="ShipAddress" HeaderText="ShipAddress" SortExpression="ShipAddress"
                        UniqueName="ShipAddress">
                    </telerik:GridBoundColumn>
                    <telerik:GridBoundColumn DataField="ShipPostalCode" HeaderText="ShipPostalCode" SortExpression="ShipPostalCode"
                        UniqueName="ShipPostalCode">
                    </telerik:GridBoundColumn>
                    <telerik:GridButtonColumn CommandName="Delete" ButtonType="ImageButton" />
                </Columns>
                <EditFormSettings EditFormType="Template">
                    <EditColumn UniqueName="EditCommandColumn1">
                    </EditColumn>
                    <FormTemplate>
                        <table cellspacing="2" cellpadding="1" width="100%" border="0">
                            <tr>
                                <td colspan="2">
                                    <b>Order:
                                        <%# Eval("OrderID") %>
                                    </b>
                                </td>
                            </tr>
                            <tr>
                                <td>
                                    OrderDate:
                                </td>
                                <td>
                                    <asp:TextBox Width="200px" ID="TextBox1" runat="server" Text='<%# Bind("OrderDate") %>'></asp:TextBox>
                                </td>
                            </tr>
                            <tr>
                                <td>
                                    Freight:
                                </td>
                                <td>
                                    <asp:TextBox Width="200px" ID="TextBox2" runat="server" Text='<%# Bind("Freight") %>'></asp:TextBox>
                                </td>
                            </tr>
                            <tr>
                                <td>
                                    ShipAddress:
                                </td>
                                <td>
                                    <asp:TextBox Width="200px" ID="TextBox3" runat="server" Text='<%# Bind("ShipAddress") %>'></asp:TextBox>
                                </td>
                            </tr>
                            <tr>
                                <td>
                                    ShipPostalCode:
                                </td>
                                <td>
                                    <asp:TextBox Width="200px" ID="TextBox4" runat="server" Text='<%# Bind("ShipPostalCode") %>'></asp:TextBox>
                                </td>
                            </tr>
                            <tr>
                                <td colspan="2">
                                    <asp:Button ID="Button1" runat="server" Text='<%# (Container is GridEditFormInsertItem) ? "Insert" : "Update" %>'
                                        CommandName='<%# (Container is GridEditFormInsertItem) ? "PerformInsert" : "Update" %>'>
                                    </asp:Button>
                                    <asp:Button ID="Button2" runat="server" Text="Cancel" CausesValidation="false" CommandName="Cancel">
                                    </asp:Button>
                                </td>
                            </tr>
                        </table>
                    </FormTemplate>
                </EditFormSettings>
            </MasterTableView>
        </telerik:RadGrid>
        <asp:SqlDataSource id="SessionDataSource1" runat="server" conflictdetection="CompareAllValues" connectionstring="<%$ ConnectionStrings:NorthwindConnectionString %>"
            providername="System.Data.SqlClient" selectcommand="SELECT [OrderID], [OrderDate], [Freight], [ShipAddress], [ShipPostalCode] FROM [Orders]"
            deletecommand="DELETE FROM [Orders] WHERE [OrderID] = ?" oldvaluesparameterformatstring="original_{0}"
            insertcommand="INSERT INTO [Orders] ([OrderDate], [Freight], [ShipAddress], [ShipPostalCode]) VALUES (?, ?, ?, ?)"
            updatecommand="UPDATE [Orders] SET [OrderDate] = ?, [Freight] = ?, [ShipAddress] = ?, [ShipPostalCode] = ? WHERE [OrderID] = ?">
                <DeleteParameters>
                    <asp:Parameter Name="OrderID" Type="Int32" />
                </DeleteParameters>
                <UpdateParameters>
                    <asp:Parameter Name="OrderDate" Type="DateTime" />
                    <asp:Parameter Name="Freight" Type="Decimal" />
                    <asp:Parameter Name="ShipAddress" Type="String" />
                    <asp:Parameter Name="ShipPostalCode" Type="String" />
                    <asp:Parameter Name="OrderID" Type="Int32" />
                </UpdateParameters>
                <InsertParameters>
                    <asp:Parameter Name="OrderDate" Type="DateTime" />
                    <asp:Parameter Name="Freight" Type="Decimal" />
                    <asp:Parameter Name="ShipAddress" Type="String" />
                    <asp:Parameter Name="ShipPostalCode" Type="String" />
                </InsertParameters>
            </asp:SqlDataSource>
    </div>
    </form>
</body>
</html>
