After click on page 2 on the GridView my link view option which is inside the GridView does not response.
Please help.
HTML
<%@ Page Language="vb" AutoEventWireup="false" CodeBehind="CommentingPre.aspx.vb" Inherits="SMIS2022WEB.CommentingPre" %>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
<style type="text/css">
.auto-style1 { width: 100%; border-style: solid; border-width: 1px; }
.auto-style2 { border-style: solid; border-width: 1px; }
.auto-style4 { border-style: solid; border-width: 1px; width: 74px; }
</style>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:Panel ID="Panel1" runat="server" Height="497px">
<table class="auto-style1">
<tr>
<td class="auto-style2">Term</td>
<td class="auto-style2">
<asp:DropDownList ID="ddlterm" runat="server">
<asp:ListItem>NONE</asp:ListItem>
<asp:ListItem>I</asp:ListItem>
<asp:ListItem>II</asp:ListItem>
<asp:ListItem>III</asp:ListItem>
</asp:DropDownList>
</td>
<td class="auto-style2">Class</td>
<td class="auto-style2">
<asp:DropDownList ID="Classdll" runat="server" AutoPostBack="True" DataSourceID="dclass" DataTextField="CLASS" DataValueField="CLASS">
</asp:DropDownList>
<asp:SqlDataSource ID="dclass" runat="server" ConnectionString="<%$ ConnectionStrings:SMIS2022ConnectionString %>" SelectCommand="SELECT [CLASS] FROM [CLASS]"></asp:SqlDataSource>
</td>
<td class="auto-style2">Stream</td>
<td class="auto-style4">
<asp:DropDownList ID="Streamddl" runat="server" AutoPostBack="True" DataSourceID="Stremdd" DataTextField="Stream" DataValueField="Stream" Style="margin-left: 0px">
</asp:DropDownList>
<asp:SqlDataSource ID="Stremdd" runat="server" ConnectionString="<%$ ConnectionStrings:SMIS2022ConnectionString %>" SelectCommand="SELECT [Stream] FROM [Streamdata]"></asp:SqlDataSource>
</td>
<td class="auto-style4">
<asp:Button ID="Button1" runat="server" Text="Go" />
</td>
<td class="auto-style4">
<asp:Button ID="Button3" runat="server" Text="Save Data" />
</td>
<td class="auto-style2" colspan="2">Hide Class Teacher
<asp:CheckBox ID="CheckBox2" runat="server" AutoPostBack="True" />
Hide Headteacher
<asp:CheckBox ID="CheckBox3" runat="server" AutoPostBack="True" />
</td>
</tr>
<tr>
<td class="auto-style2"></td>
<td class="auto-style2"></td>
<td class="auto-style2"></td>
<td class="auto-style2"></td>
<td class="auto-style2" colspan="2">
<asp:Button ID="Button2" runat="server" Text="Back To Menu" />
</td>
<td class="auto-style4"></td>
<td class="auto-style4"></td>
<td class="auto-style2">
<asp:Button ID="Button4" runat="server" Text="Register Subject Comment" Width="191px" />
</td>
<td class="auto-style2">
<asp:Button ID="Button5" runat="server" Text="Register Class Teacher Comment" Width="226px" />
</td>
</tr>
<tr>
<td class="auto-style2" colspan="10">
<asp:ScriptManager ID="ScriptManager1" runat="server">
</asp:ScriptManager>
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<ContentTemplate>
<asp:GridView ID="TeachersCommentsGrd" runat="server" AutoGenerateColumns="False" Width="889px" AllowPaging="True" PageSize="28" OnRowDataBound="OnRowDataBound">
<Columns>
<asp:TemplateField>
<HeaderTemplate>
<asp:CheckBox ID="chkAll" runat="server" AutoPostBack="true" />
</HeaderTemplate>
<ItemTemplate>
<asp:CheckBox ID="CheckBox1" runat="server" AutoPostBack="true" Enabled="False" />
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="admno">
<ItemTemplate>
<asp:TextBox ID="Admno" runat="server" Text='<%# Eval("admno") %>' ReadOnly="True" Height="16px" Width="83px"></asp:TextBox>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Student Name">
<EditItemTemplate>
<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
</EditItemTemplate>
<ItemTemplate>
<asp:TextBox ID="Names" runat="server" Text='<%# Eval("name") %>' ReadOnly="True"></asp:TextBox>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Teachers Comments">
<ItemTemplate>
<asp:TextBox ID="TeacherComments" runat="server" Height="16px" Width="568px" OnTextChanged="TeacherComments_TextChanged" Text='<%# Eval("classteachercomment") %>' CssClass="TeacherComments" onkeyup="enter(this)" AutoPostBack="True"></asp:TextBox>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="HeadTeachers Comments" Visible="False">
<ItemTemplate>
<asp:TextBox ID="Headcomments" runat="server" Height="17px" Width="288px" OnTextChanged="Headcomments_TextChanged" Text='<%# Eval("headcom") %>' CssClass="Headcomments" onkeyup="enter(this)" AutoPostBack="true"></asp:TextBox>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="CommentSelect" Visible="False">
<ItemTemplate>
<asp:DropDownList ID="ddlCountries" runat="server" AutoPostBack="True" OnSelectedIndexChanged="ddlCountries_SelectedIndexChanged">
</asp:DropDownList>
<asp:Label ID="lblCountry" runat="server" Text='<%# Eval("classteachercomment") %>' Visible="False"></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Promotion " Visible="False">
<ItemTemplate>
<asp:TextBox ID="Promotion" runat="server" AutoPostBack="true" CssClass="Promotion" onkeyup="enter(this)" OnTextChanged="Promotion_TextChanged" Text='<%# Eval("Promoted") %>'></asp:TextBox>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField>
<ItemTemplate>
<asp:HyperLink ID="lnkView" runat="server" NavigateUrl="javascript:;" Text="View" />
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
<asp:HiddenField ID="hfRowIndex" runat="server" />
<asp:HiddenField ID="hfCellIndex" runat="server" />
</ContentTemplate>
</asp:UpdatePanel>
</td>
</tr>
</table>
</asp:Panel>
</div>
</form>
<script type="text/javascript" src="../Scripts/jquery-1.8.3.min.js"></script>
<script type="text/javascript">
$(function () {
$("[id*=lnkView]").click(function () {
var rowIndex = $(this).closest("tr")[0].rowIndex;
var admno = $(this).closest("tr").find("[id*=Admno]").val();
var studentName = $(this).closest("tr").find("[id*=Names]").val();
window.open("Precomments.aspx?rowIndex=" + rowIndex + "&admno=" + admno + "&studentname=" + studentName, "Popup", "width=850,height=650");
});
});
</script>
<script type="text/javascript">
function enter(obj) {
var tr = obj.parentNode.parentNode;
var cellIndex = obj.parentNode.cellIndex;
var rowIndex = obj.parentNode.parentNode.rowIndex;
if (event.keyCode == 37) //Left
{
if (cellIndex > 0)
tr.parentNode.rows[rowIndex].cells[cellIndex - 1].getElementsByTagName('INPUT')[0].focus();
//GetSelectedRow(obj)
// return;
}
if (event.keyCode == 38) //Up
{
if (rowIndex > 1)
tr.parentNode.rows[rowIndex - 1].cells[cellIndex].getElementsByTagName('INPUT')[0].focus();
// GetSelectedRow(obj)
// return;
}
if (event.keyCode == 39) //Right
{
if (cellIndex < tr.cells.length - 1)
tr.parentNode.rows[rowIndex].cells[cellIndex + 1].getElementsByTagName('INPUT')[0].focus();
// GetSelectedRow(obj)
//return;
}
if (event.keyCode == 40) //Down
{
if (rowIndex < tr.parentNode.rows.length - 1)
tr.parentNode.rows[rowIndex + 1].cells[cellIndex].getElementsByTagName('INPUT')[0].focus();
// GetSelectedRow(obj)
//return;
}
};
var prm = Sys.WebForms.PageRequestManager.getInstance();
if (prm != null) {
prm.add_endRequest(function (sender, e) {
if (sender._postBackSettings.panelsToUpdate != null) {
var rowIndex = parseInt(document.getElementById("hfRowIndex").value);
var row = document.getElementById("TeachersCommentsGrd").rows[rowIndex + 2];
if (typeof (row) != "undefined") {
var celIndex = parseInt(document.getElementById("hfCellIndex").value);
var controls = row.cells[celIndex].getElementsByTagName("INPUT");
for (var i = 0; i < controls.length; i++) {
switch (controls[i].className) {
case "Headcomments":
controls[i].focus();
return;
break;
case "Promotion":
controls[i].focus();
return;
break;
case "TeacherComments":
controls[i].focus();
return;
default:
}
}
}
}
});
}
</script>
</body>
</html
This Link view does not response when i go to next page in GridView.
<asp:TemplateField>
<ItemTemplate>
<asp:HyperLink ID="lnkView" runat="server" NavigateUrl="javascript:;" Text="View" />
</ItemTemplate>
</asp:TemplateField>