<%@ 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 runat="server"> 
    // 
    protected void RadioCheckedChanged(object sender, System.EventArgs e) 
    { 
        switch ((sender as RadioButton).ID) 
        { 
            case "RadioButton1": 
                { 
                    shippersGrid.MasterTableView.EditMode = GridEditMode.EditForms; 
                    RadioButton2.Checked = false; 
                    break; 
                } 
            case "RadioButton2": 
                { 
                    shippersGrid.MasterTableView.EditMode = GridEditMode.InPlace; 
                    RadioButton1.Checked = false; 
                    break; 
                } 
        } 
        shippersGrid.Rebind(); 
    } 
    // 
    protected void shippersDataSource_Deleted(object sender, SqlDataSourceStatusEventArgs e) 
    { 
        if (e.Exception != null) 
        { 
            messageLabel.Text = e.Exception.Message; 
            e.ExceptionHandled = true; 
        } 
    } 
    // 
    protected void shippersDataSource_Updated(object sender, SqlDataSourceStatusEventArgs e) 
    { 
        if (e.Exception != null) 
        { 
            messageLabel.Text = e.Exception.Message; 
            e.ExceptionHandled = true; 
        } 
    } 
    // 
    protected void shippersDataSource_Inserted(object sender, SqlDataSourceStatusEventArgs e) 
    { 
        if (e.Exception != null) 
        { 
            messageLabel.Text = e.Exception.Message; 
            e.ExceptionHandled = true; 
        } 
    } 
</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>
<div style="float: left; margin-left: 30px;"> 
            <asp:RadioButton ID="RadioButton1" AutoPostBack="True" Text="In-forms editing mode" 
            runat="server" Checked="True" oncheckedchanged="RadioCheckedChanged" /> 
        </div> 
        <div style="float: left;"> 
            <asp:RadioButton ID="RadioButton2" AutoPostBack="True" Text="In-line editing mode" 
            runat="server" oncheckedchanged="RadioCheckedChanged" /> 
        </div> 
        <telerik:radgrid  
            ID="shippersGrid" runat="server"  
            DataSourceID="shippersDataSource"  
            GridLines="None"  
            AllowPaging="True"  
            AutoGenerateColumns="False" 
            allowautomaticdeletes="True"  
            allowautomaticinserts="True"  
            allowautomaticupdates="True"  
            Skin="Office2007"  
            > 
            <MasterTableView  
                CommandItemDisplay="Top"  
                DataSourceID="shippersDataSource"  
                > 
                <Columns> 
                    <Telerik:GridEditCommandColumn EditText="Edit" /> 
                    <Telerik:GridTemplateColumn HeaderText="Shipper Via" UniqueName="ShipperIDColumn" AllowFiltering="False" > 
                        <ItemTemplate> 
                            <asp:Label ID="ShipperIDLabel" runat="server" Text='<%# Eval("ShipperID") %>' /> 
                        </ItemTemplate> 
                        <EditItemTemplate> 
                            <asp:Label ID="ShipperIDLabel" runat="server" Text='<%# Eval("ShipperID") %>' /> 
                        </EditItemTemplate> 
                    </Telerik:GridTemplateColumn> 
                    <Telerik:GridBoundColumn DataField="CompanyName" UniqueName="CompanyNameColumn" HeaderText="Company Name" /> 
                    <Telerik:GridBoundColumn DataField="Phone" UniqueName="PhoneColumn" HeaderText="Phone" /> 
                    <Telerik:GridButtonColumn Text="Delete" CommandName="Delete"  
                        UniqueName="DeleteColumn"  
                        ConfirmText="Are you sure you want to delete this data?" /> 
                </Columns> 
                <ExpandCollapseColumn> 
                <HeaderStyle Width="20px"></HeaderStyle> 
                </ExpandCollapseColumn> 
                <RowIndicatorColumn> 
                <HeaderStyle Width="20px"></HeaderStyle> 
                </RowIndicatorColumn> 
                <EditItemStyle CssClass="EditedTelerikGrid"/> 
                <EditFormSettings > 
                    <EditColumn  
                        UniqueName="EditCommandColumn" 
                        InsertText="Save" 
                        UpdateText="Save" 
                        CancelText="Cancel" 
                        > 
                    </EditColumn> 
                    <FormMainTableStyle CssClass="EditedTelerikGrid" /> 
                </EditFormSettings> 
                <CommandItemSettings AddNewRecordText="Add"  RefreshText="Refresh" /> 
            </MasterTableView> 
            <FilterMenu EnableTheming="True" Skin="Office2007"> 
                <CollapseAnimation Duration="200" Type="OutQuint" /> 
            </FilterMenu> 
        </telerik:radgrid> 
        <br /> 
        <asp:SqlDataSource ID="shippersDataSource" runat="server"  
            ConnectionString="<%$ ConnectionStrings:ConnectionString %>"  
            DeleteCommand="DELETE FROM [Shippers] WHERE [ShipperID] = @ShipperID"  
            InsertCommand="INSERT INTO [Shippers] ([CompanyName], [Phone]) VALUES (@CompanyName, @Phone)"  
            SelectCommand="SELECT [ShipperID], [CompanyName], [Phone] FROM [Shippers]"  
             
            UpdateCommand="UPDATE [Shippers] SET [CompanyName] = @CompanyName, [Phone] = @Phone WHERE [ShipperID] = @ShipperID"  
            ondeleted="shippersDataSource_Deleted"  
            onupdated="shippersDataSource_Updated"  
            oninserted="shippersDataSource_Inserted"> 
            <DeleteParameters> 
                <asp:Parameter Name="ShipperID" Type="Int32" /> 
            </DeleteParameters> 
            <UpdateParameters> 
                <asp:Parameter Name="CompanyName" Type="String" /> 
                <asp:Parameter Name="Phone" Type="String" /> 
                <asp:Parameter Name="ShipperID" Type="Int32" /> 
            </UpdateParameters> 
            <InsertParameters> 
                <asp:Parameter Name="CompanyName" Type="String" /> 
                <asp:Parameter Name="Phone" Type="String" /> 
            </InsertParameters> 
        </asp:SqlDataSource> 
        <asp:Label ID="messageLabel" runat="server" Text="" ></asp:Label> 
	</div>
	</form>
</body>
</html>
