<%@ 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>
</head>
<body>
    <form id="form1" runat="server">
    <asp:ScriptManager ID="ScriptManager1" runat="server">
    </asp:ScriptManager>
    <telerik:RadScriptBlock ID="ScriptBlock1" runat="server">

        <script type="text/javascript">

            function onCommand(sender, args) {


            }

            var selectedIndexes = [];
            var lastIndex;
        
            function onKeyPressed(sender, args) {


                if (args.get_keyCode() == 13)
                {
                    args.set_cancel(true);   
                    selectedIndexes.push(lastIndex);                                     
                }
                
            }

            function rowSelecting(sender, args) 
            {                
                lastIndex = args.get_itemIndexHierarchical();                          
            }

            function rowDeselecting(sender, args) 
            {
                var index = args.get_itemIndexHierarchical();
                
                for(var i=0; i < selectedIndexes.length; i++)
                {
                    if (selectedIndexes[i] == index)
                    {
                        args.set_cancel(true);
                    }
                }
            }
        
        
        </script>

    </telerik:RadScriptBlock>
    <telerik:RadAjaxManager ID="RadAjaxManager1" runat="server">
        <AjaxSettings>
            <telerik:AjaxSetting AjaxControlID="RadGrid1">
                <UpdatedControls>
                    <telerik:AjaxUpdatedControl ControlID="RadGrid1" />
                </UpdatedControls>
            </telerik:AjaxSetting>
        </AjaxSettings>
    </telerik:RadAjaxManager>
    <telerik:RadGrid ID="RadGrid1" AllowMultiRowSelection="true" runat="server" EnableLinqExpressions="false"
        DataSourceID="SqlDataSource1">
        <MasterTableView AutoGenerateColumns="False" AllowFilteringByColumn="true" AllowSorting="true"
            AllowPaging="true" DataKeyNames="EmployeeID" DataSourceID="SqlDataSource1">
            <Columns>
                <telerik:GridBoundColumn DataField="EmployeeID" DataType="System.Int32" HeaderText="EmployeeID"
                    ReadOnly="True" SortExpression="EmployeeID" UniqueName="EmployeeID">
                </telerik:GridBoundColumn>
                <telerik:GridBoundColumn DataField="LastName" HeaderText="LastName" SortExpression="LastName"
                    UniqueName="LastName">
                </telerik:GridBoundColumn>
                <telerik:GridBoundColumn DataField="FirstName" HeaderText="FirstName" SortExpression="FirstName"
                    UniqueName="FirstName">
                </telerik:GridBoundColumn>
                <telerik:GridBoundColumn DataField="City" HeaderText="City" SortExpression="City"
                    UniqueName="City">
                </telerik:GridBoundColumn>
                <telerik:GridBoundColumn DataField="Country" HeaderText="Country" SortExpression="Country"
                    UniqueName="Country">
                </telerik:GridBoundColumn>
                <telerik:GridBoundColumn DataField="BirthDate" DataType="System.DateTime" HeaderText="BirthDate"
                    SortExpression="BirthDate" UniqueName="BirthDate">
                </telerik:GridBoundColumn>
            </Columns>
        </MasterTableView>
        <ClientSettings AllowKeyboardNavigation="true" Selecting-AllowRowSelect="true">
            <ClientEvents OnCommand="onCommand" OnRowDeselecting="rowDeselecting" OnRowSelecting="rowSelecting"
                OnKeyPress="onKeyPressed" />
        </ClientSettings>
    </telerik:RadGrid>
    <asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:ConnectionString %>"
        SelectCommand="SELECT [EmployeeID], [LastName], [FirstName], [City], [Country], [BirthDate] FROM [Employees]">
    </asp:SqlDataSource>
    </form>
</body>
</html>
