<%@ 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>Untitled Page</title>
</head>
<body>
    <form id="form1" runat="server">
        <asp:ScriptManager ID="ScriptManager" runat="server" />        
        <div>
            <rad:RadCalendar ID="RadCalendar1" runat="server" Font-Names="Arial, Verdana, Tahoma"
                ForeColor="Black" Style="border-color: #ececec">
            </rad:RadCalendar>
            <telerik:RadAjaxManager ID="RadAjaxManager1" runat="server">
                <AjaxSettings>
                    <telerik:AjaxSetting AjaxControlID="RadGrid1">
                        <UpdatedControls>
                            <telerik:AjaxUpdatedControl ControlID="RadGrid1" />
                            <telerik:AjaxUpdatedControl ControlID="RadInputManager1" />
                        </UpdatedControls>
                    </telerik:AjaxSetting>
                </AjaxSettings>
            </telerik:RadAjaxManager>
            <telerik:RadInputManager ID="RadInputManager1" runat="server" Skin="SkyBlue">
                <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" IsRequiredFields="true"
                    ValidationExpression="[\w\d-]{4,10}">
                </telerik:RegExpTextBoxSetting>
            </telerik:RadInputManager>
            <telerik:RadGrid ID="RadGrid1" runat="server" DataSourceID="SessionDataSource1" Skin="Telerik"
                AllowMultiRowEdit="true" GridLines="None" AllowPaging="True" OnItemDataBound="RadGrid1_ItemDataBound"
                AllowAutomaticUpdates="true" AllowAutomaticInserts="true" AllowAutomaticDeletes="true"
                AllowSorting="true">
                <MasterTableView AutoGenerateColumns="False" DataKeyNames="OrderID" DataSourceID="SessionDataSource1"
                    CommandItemDisplay="Top">
                    <PagerStyle Mode="NextPrevNumericAndAdvanced" />
                    <Columns>
                        <telerik:GridEditCommandColumn>
                        </telerik:GridEditCommandColumn>
                        <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">
                        </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" Text="Delete">
                        </telerik:GridButtonColumn>
                    </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:LinkButton ID="LinkButton1" runat="server" Text='<%# (Container is GridEditFormInsertItem) ? "Insert" : "Update" %>'
                                            CommandName='<%# (Container is GridEditFormInsertItem) ? "PerformInsert" : "Update" %>'></asp:LinkButton>
                                        <asp:LinkButton ID="LinkButton2" runat="server" Text="Cancel" CausesValidation="false"
                                            CommandName="Cancel"></asp:LinkButton>
                                    </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>
