Please he my arrow key on the grid remains in the same position despite pressing. when i try to debug the code it shows that i has run well but on the grid it remains in that very cell.
please help.
<%@ Page Language="vb" AutoEventWireup="false" CodeBehind="Classinterview.aspx.vb" Inherits="INTERVIEWSVB.Classinterview" %>
<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="asp" %>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
<script type = "text/javascript">
function askConfirm(msg) {
alert(msg)
}
</script>
<script type = "text/javascript">
function askConfirmk(msg) {
alert(msg)
return true;
}
</script>
<script type="text/javascript">
function enter(obj) {
var tr = obj.parentNode.parentNode.parentNode;
var cellIndex = obj.parentNode.parentNode.cellIndex;
if (event.keyCode == 37) //Left
{
if (cellIndex > 0)
tr.parentNode.rows[tr.rowIndex].cells[cellIndex - 1].children[0].focus();
return;
}
if (event.keyCode == 38) //Up
{
if (tr.rowIndex > 1)
tr.parentNode.rows[tr.rowIndex - 1].cells[cellIndex].children[0].focus();
return;
}
if (event.keyCode == 39) //Right
{
if (cellIndex < tr.cells.length - 1)
tr.parentNode.rows[tr.rowIndex].cells[cellIndex + 1].children[0].focus();
return;
}
if (event.keyCode == 40) //Down
{
if (tr.rowIndex < tr.parentNode.rows.length - 1)
tr.parentNode.rows[tr.rowIndex + 1].cells[cellIndex].children[0].focus();
return;
}
}
</script>
<script type = "text/javascript">
function GetSelectedRow(UserLink) {
var row = UserLink.parentNode.parentNode.parentNode;
var rowIndex = row.rowIndex - 1;
var userId = row.cells[0].innerHTML;
var lable = row.getElementsByTagName("input")[2].value;
if (lable == null || lable == "") {
row.getElementsByTagName("input")[0].value = "d";
return true;
} else {
row.getElementsByTagName("input")[0].value = "";
}
if (lable >= 0 && lable <= 100) {
return true;
} else {
alert("Must be between 1 and 100");
return false;
}
}
</script>
</head>
<body>
<form id="form1" runat="server">
<asp:GridView ID="GvStudentMarks" runat="server" AutoGenerateColumns="False" OnRowDataBound="gvStudentMarks_RowDataBound" AllowPaging="True" PageSize="20">
<Columns>
<asp:TemplateField>
<HeaderTemplate>
<asp:CheckBox ID = "chkAll" runat="server" AutoPostBack="true" />
</HeaderTemplate>
<ItemTemplate>
<asp:CheckBox ID="CheckBox1" runat="server" AutoPostBack="true" />
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Account">
<EditItemTemplate>
<asp:TextBox ID="TextBox1" runat="server" Text='<%# Bind("Account") %>'></asp:TextBox>
</EditItemTemplate>
<ItemTemplate>
<asp:Label ID="Label6" runat="server" Text='<%# Bind("Account") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Name">
<EditItemTemplate>
<asp:TextBox ID="TextBox2" runat="server" Text='<%# Bind("Name") %>'></asp:TextBox>
</EditItemTemplate>
<ItemTemplate>
<asp:Label ID="Label3" runat="server" Text='<%# Bind("Name") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Category">
<EditItemTemplate>
<asp:TextBox ID="TextBox3" runat="server" Text='<%# Bind("Category") %>'></asp:TextBox>
</EditItemTemplate>
<ItemTemplate>
<asp:Label ID="Label4" runat="server" Text='<%# Bind("Category") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Stream">
<EditItemTemplate>
<asp:TextBox ID="TextBox4" runat="server" Text='<%# Bind("Stream") %>'></asp:TextBox>
</EditItemTemplate>
<ItemTemplate>
<asp:Label ID="Label5" runat="server" Text='<%# Bind("Stream") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Eng">
<ItemTemplate>
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<ContentTemplate>
<asp:Label ID="lblEng" runat="server" Text='<%# Eval("Eng") %>' Visible="False"></asp:Label>
<asp:TextBox ID="TxtEng" runat="server" OnTextChanged="txtEng_TextChanged" Text='<%# Eval("Eng") %>' onkeyup="enter(this)" AutoPostBack="True" Height="16px" Width="58px" ></asp:TextBox>
<asp:RangeValidator ID="RangeValidator1" runat="server" BackColor="#FF99FF" ControlToValidate="TxtEng" Display="Dynamic" ErrorMessage="Invalid" MaximumValue="100" MinimumValue="0" SetFocusOnError="True" Type="Double"></asp:RangeValidator>
</ContentTemplate>
</asp:UpdatePanel>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Maths">
<ItemTemplate>
<asp:UpdatePanel ID="UpdatePanel2" runat="server">
<ContentTemplate>
<asp:Label ID="lblMaths" runat="server" Text='<%# Eval("Maths") %>' Visible="False"></asp:Label>
<asp:TextBox ID="TxtMaths" runat="server" OnTextChanged="txtMaths_TextChanged" Text='<%# Eval("Maths") %>' onkeyup="enter(this)" AutoPostBack="True" Width="48px"></asp:TextBox>
<asp:RangeValidator ID="RangeValidator2" runat="server" BackColor="#FF99FF" ControlToValidate="TxtMaths" Display="Dynamic" ErrorMessage="Invalid" MaximumValue="100" MinimumValue="0" SetFocusOnError="True" Type="Double"></asp:RangeValidator>
</ContentTemplate>
</asp:UpdatePanel>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="TotalMarks">
<ItemTemplate>
<asp:Label ID="lblTotalMarks" runat="server" Text='<%# Eval("avgs") %>' Visible="False"></asp:Label>
<asp:TextBox ID="txtTotalmarks" runat="server" Text='<%# Eval("Avgs") %>' ReadOnly="True" Width="49px"></asp:TextBox>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Average">
<ItemTemplate>
<asp:TextBox ID="txtAverage" runat="server" Text='<%# Eval("Avgs2") %>' ReadOnly="True" Width="48px"></asp:TextBox>
</ItemTemplate>
</asp:TemplateField>
<asp:BoundField HeaderText="Sst" DataField="Sst" />
<asp:BoundField DataField="Science" HeaderText="Science" />
<asp:TemplateField HeaderText="Entered Date">
<EditItemTemplate>
<asp:TextBox ID="Entrydate" runat="server" Text='<%# Bind("emarksdate") %>'></asp:TextBox>
</EditItemTemplate>
<ItemTemplate>
<asp:Label ID="Label1" runat="server" Text='<%# Bind("emarksdate") %>'></asp:Label>
<asp:TextBox ID="Entrydates" runat="server" Text='<%# Eval("emarksdate") %>'></asp:TextBox>
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
</form>
</body>
</html>