Some times it happens that our web have a Grid View and Data Grid Contained lots of rows. Which makes Scrolling in Your page. If we clicks on a row and its redirect to another page then The Grid View and Data Grid Becomes Comes on Starting Position of Gridview or DataGrid. For Setting Your Grid View and Data Grid On Last Row Position the Given Below Property can be used.
Property of Page:
MaintainScrollPositionOnPostback ="true"
Example:
Property of Page:
MaintainScrollPositionOnPostback ="true"
Example:
<%@ Page Language="VB" AutoEventWireup="false" CodeFile="Reports.aspx.vb" Inherits="Reports" MaintainScrollPositionOnPostback ="true" %>
Note: If your Grid is inside the Update panel then will not work. For Update Panel we use Given Below Process:
Steps:-
1. Put Given Below Script under the Script Manager tag.
Note: If your Grid is inside the Update panel then will not work. For Update Panel we use Given Below Process:
Steps:-
1. Put Given Below Script under the Script Manager tag.
<asp:ScriptManager ID="ScriptManager1" runat="server" />
<script type="text/javascript" language="javascript">
var
prmExotic = Sys.WebForms.PageRequestManager.getInstance();
prmExotic.add_pageLoaded(pageLoaded);
function
pageLoaded(sender, args) {
Exotic()
}
function
Exotic()
{//document.getElementById("hdnScrollTop").value
document.getElementById("divExotic").scrollTop
=document.getElementById("Hidden2").value;
}
function
FuncExotic()
{
var
s=document.getElementById("divExotic").scrollTop;
document.getElementById('Hidden2').value=s;
}
</Script>
2. Put the Hidden Field Text Box Just below the Body tag.
<input type="hidden" id="Hidden2" runat="server"
value="0"/>
3. Keep DataGrid and Gridview Control Inside the Given Below Div Tag.
<div runat="server"
id="divExotic"
style="width:580px;height:700px;
overflow-x:hidden; overflow-y:scroll; text-align: left;" onscroll="FuncExotic()">
''------------ Pur Your Grid---------'
</div>
No comments:
Post a Comment