<%@ 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="ScriptManager1" runat="server">
        </asp:ScriptManager>
        <div>
            <telerik:RadAjaxManager ID="RadAjaxManager1" runat="server">
                <AjaxSettings>
                    <telerik:AjaxSetting AjaxControlID="RadGrid1">
                        <UpdatedControls>
                            <telerik:AjaxUpdatedControl ControlID="RadGrid1" />
                            <telerik:AjaxUpdatedControl ControlID="Label1" />
                        </UpdatedControls>
                    </telerik:AjaxSetting>
                </AjaxSettings>
            </telerik:RadAjaxManager>
            <telerik:RadCodeBlock ID="RadCodeBlock1" runat="server">

                <script type="text/javascript">
                function DeleteRows()
                {
                    var masterTable = $find("<%= RadGrid1.ClientID %>").get_masterTableView();
                    masterTable.fireCommand("DeleteSelected","");  
                    return false;            
                }
                </script>

            </telerik:RadCodeBlock>
            <telerik:RadGrid ID="RadGrid1" AllowAutomaticUpdates="true" AllowAutomaticDeletes="true"
                Skin="Vista" DataSourceID="SessionDataSource1" Width="97%" AllowSorting="True"
                AutoGenerateColumns="true" AllowPaging="True" GridLines="None" runat="server"
                ShowFooter="True" AllowMultiRowSelection="True" PageSize="7" AllowMultiRowEdit="True"
                HorizontalAlign="NotSet" OnItemDeleted="RadGrid1_ItemDeleted" OnItemCommand="RadGrid2_ItemCommand">
                <PagerStyle Mode="NextPrevAndNumeric" />
                <MasterTableView Width="100%" GridLines="None" CommandItemDisplay="Top" DataSourceID="SessionDataSource1"
                    EditMode="InPlace" HorizontalAlign="NotSet" DataKeyNames="CustomerID" AllowAutomaticInserts="True">
                    <CommandItemTemplate>
                        <div style="padding: 0 5px;">
                            <asp:LinkButton ID="LinkButton1" OnClientClick="return DeleteRows();" runat="server">
                                <img style="border:0px;vertical-align:middle;" alt="" src="Img/Delete.gif" />Delete selected customers</asp:LinkButton>&nbsp;&nbsp;
                            <asp:LinkButton ID="LinkButton4" runat="server" CommandName="RebindGrid">
                                <img style="border:0px;vertical-align:middle;" alt="" src="Img/Refresh.gif" />Refresh customer list</asp:LinkButton>
                        </div>
                    </CommandItemTemplate>
                </MasterTableView>
                <ClientSettings>
                    <Selecting AllowRowSelect="True" EnableDragToSelectRows="True" />
                </ClientSettings>
            </telerik:RadGrid>
            <asp:AccessDataSource ID="SessionDataSource1" DataFile="~/App_Data/Nwind.mdb" SelectCommand="SELECT [CustomerID], [CompanyName], [ContactName], [ContactTitle], [Address], [City] FROM [Customers]"
                runat="server" ConflictDetection="CompareAllValues" OldValuesParameterFormatString="original_{0}"
                DeleteCommand="DELETE FROM [Customers] WHERE [CustomerID] = ?" InsertCommand="INSERT INTO [Customers] ([CustomerID], [CompanyName], [ContactName], [ContactTitle], [Address], [City]) VALUES (?, ?, ?, ?, ?, ?)"
                UpdateCommand="UPDATE [Customers] SET [CompanyName] = ?, [ContactName] = ?, [ContactTitle] = ?, [Address] = ?, [City] = ? WHERE [CustomerID] = ? AND [CompanyName] = ? AND [ContactName] = ? AND [ContactTitle] = ? AND [Address] = ? AND [City] = ?">
                <UpdateParameters>
                    <asp:Parameter Name="CompanyName" Type="String" />
                    <asp:Parameter Name="ContactName" Type="String" />
                    <asp:Parameter Name="ContactTitle" Type="String" />
                    <asp:Parameter Name="Address" Type="String" />
                    <asp:Parameter Name="City" Type="String" />
                    <asp:Parameter Name="original_CustomerID" Type="String" />
                    <asp:Parameter Name="original_CompanyName" Type="String" />
                    <asp:Parameter Name="original_ContactName" Type="String" />
                    <asp:Parameter Name="original_ContactTitle" Type="String" />
                    <asp:Parameter Name="original_Address" Type="String" />
                    <asp:Parameter Name="original_City" Type="String" />
                </UpdateParameters>
                <DeleteParameters>
                    <asp:Parameter Name="original_CustomerID" Type="String" />
                </DeleteParameters>
                <InsertParameters>
                    <asp:Parameter Name="CustomerID" Type="String" />
                    <asp:Parameter Name="CompanyName" Type="String" />
                    <asp:Parameter Name="ContactName" Type="String" />
                    <asp:Parameter Name="ContactTitle" Type="String" />
                    <asp:Parameter Name="Address" Type="String" />
                    <asp:Parameter Name="City" Type="String" />
                </InsertParameters>
            </asp:AccessDataSource>
            <asp:Label ID="Label1" runat="server"></asp:Label>
        </div>
    </form>
</body>
</html>
