Keep in mind that the MaintainScrollPositionOnPostback is to be placed/used in the @Page directive, not in the GridView.
Also, a hyperlink technicalliy not really a post-back. You can of course use a "regular" button in a GV such as say this example GV in which I have a row edit:
<asp:GridView ID="GHotels" runat="server" AutoGenerateColumns="False"
DataKeyNames="ID" Width="50%"
CssClass="table table-hover table-striped"
>
<Columns>
<asp:BoundField DataField="FirstName" HeaderText="FirstName" />
<asp:BoundField DataField="LastName" HeaderText="LastName" />
<asp:BoundField DataField="HotelName" HeaderText="HotelName" />
<asp:TemplateField HeaderText="Active" ItemStyle-HorizontalAlign="Center">
<ItemTemplate>
<asp:CheckBox ID="chkActive" runat="server"
Checked='<%# Eval("Active") %>' />
</ItemTemplate>
</asp:TemplateField>
<asp:BoundField DataField="Description" HeaderText="Description" />
<asp:TemplateField HeaderText="Hotel Information" ItemStyle-HorizontalAlign="Center">
<ItemTemplate>
<asp:Button ID="cmdView" runat="server" Text="Edit"
OnClick="cmdView_Click" CssClass="btn" />
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
So, in place of a hyper-link button, I just used a standard asp.net button.
The code behind that picks up the current row click is thus this:
Protected Sub cmdView_Click(sender As Object, e As EventArgs)
' Row click - get hotel informaton, fill out the pop div
Dim btn As Button = sender
Dim gRow As GridViewRow = btn.NamingContainer
Dim intPK As Integer = GHotels.DataKeys(gRow.RowIndex).Item("ID")
Dim rstData As DataTable
rstData = MyRst($"SELECT * FROM tblHotelsA WHERE ID = {intPK}")
Call fLoader(HotelInfo, rstData.Rows(0)) ' Load up conrols in div
' call our js pop function.
Dim strHotelName = $"Edit Information for {rstData.Rows(0).Item("HotelName")}"
Dim strJavaScript As String =
$"popinfo('{btn.ClientID}','{strHotelName}');"
ScriptManager.RegisterStartupScript(Page, Page.GetType, "mypop", strJavaScript, True)
End Sub
Note the use of NamingContainer - that allows you to pick up the current row. Combined with the page direction, say like this:
<%@ Page Language="vb" AutoEventWireup="false"
CodeBehind="HotelInfoPop.aspx.vb"
Inherits="MyCalendar.HotelInfoPop"
MaintainScrollPositionOnPostback="true"
%>
So, above does return scroll position on post-back.
So, we might need more markup, since the above does maintain the current screen scroll position. Perhaps a update panel is involved here?