<%@ Page Language="C#" AutoEventWireup="true" CodeFile="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" />
</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" />
			<asp:ScriptReference Assembly="Telerik.Web.UI" Name="Telerik.Web.UI.Common.jQueryInclude.js" />
		</Scripts>
	</telerik:RadScriptManager>
    <telerik:RadCodeBlock ID="RadCodeBlock1" runat="server">
    <script type="text/javascript">
        var selectedIndex = -1;
        function rowSelected(sender, eventArgs) {
            selectedIndex = eventArgs.get_itemIndexHierarchical();
        }

        function rowDeselected(sender, eventArgs) {
            selectedIndex = -1;
        }

        function keyPress(sender, eventArgs) {
            if (selectedIndex != -1) {
                if (eventArgs.get_keyCode() == 9) {
                    var grid = $find("<%=RadGrid1.ClientID %>");
                    var row = grid.get_masterTableView().get_dataItems()[selectedIndex-1];
                    row.findElement("TextBox1").focus();
                    selectedIndex = -1;
                }
            }
        }
    </script>
    </telerik:RadCodeBlock>	
    <div>
    <telerik:RadGrid ID="RadGrid1" runat="server" AllowFilteringByColumn="True" 
            AllowPaging="True" AllowSorting="True" AutoGenerateColumns="False" 
            DataSourceID="AccessDataSource1" GridLines="None" ClientSettings-AllowKeyboardNavigation="true" >
	    <ClientSettings>
            <Selecting AllowRowSelect="True" />
            <ClientEvents OnRowSelected="rowSelected" OnRowDeselected="rowDeselected" OnKeyPress="keyPress" />
        </ClientSettings>
<MasterTableView DataKeyNames="ProductID" DataSourceID="AccessDataSource1">

<RowIndicatorColumn>
<HeaderStyle Width="20px"></HeaderStyle>
</RowIndicatorColumn>

<ExpandCollapseColumn>
<HeaderStyle Width="20px"></HeaderStyle>
</ExpandCollapseColumn>
    <Columns>
        <telerik:GridBoundColumn DataField="ProductID" DataType="System.Int32" 
            HeaderText="ProductID" ReadOnly="True" SortExpression="ProductID" 
            UniqueName="ProductID">
        </telerik:GridBoundColumn>
        <telerik:GridBoundColumn DataField="ProductName" HeaderText="ProductName" 
            SortExpression="ProductName" UniqueName="ProductName">
        </telerik:GridBoundColumn>
        <telerik:GridBoundColumn DataField="SupplierID" DataType="System.Int32" 
            HeaderText="SupplierID" SortExpression="SupplierID" UniqueName="SupplierID">
        </telerik:GridBoundColumn>
        <telerik:GridBoundColumn DataField="CategoryID" DataType="System.Int32" 
            HeaderText="CategoryID" SortExpression="CategoryID" UniqueName="CategoryID">
        </telerik:GridBoundColumn>
        <telerik:GridBoundColumn DataField="QuantityPerUnit" 
            HeaderText="QuantityPerUnit" SortExpression="QuantityPerUnit" 
            UniqueName="QuantityPerUnit">
        </telerik:GridBoundColumn>
        <telerik:GridTemplateColumn UniqueName="Template" HeaderText="TemplateTest" AllowFiltering="false">
        <ItemTemplate>
        <asp:TextBox ID="TextBox1" runat="server" Text="Click" />
        </ItemTemplate>
        </telerik:GridTemplateColumn>
    </Columns>
</MasterTableView>
        </telerik:RadGrid>
        <asp:AccessDataSource ID="AccessDataSource1" runat="server" 
            DataFile="~/App_Data/Nwind.mdb" 
            SelectCommand="SELECT [ProductID], [ProductName], [SupplierID], [CategoryID], [QuantityPerUnit] FROM [Alphabetical List of Products]">
        </asp:AccessDataSource>
	</div>
	</form>
</body>
</html>
