2013-06-19 2 views
0

GridView 컨트롤이 있습니다. 코드는 아래와 같습니다. 행 선택이 가능합니다. 문제는이 GridView를 아래로 스크롤하고 선택 항목이 아래쪽 행을 선택할 때 전체 GridView가 맨 위로 스크롤된다는 것입니다. Enyone은 이것을 피하는 방법을 알고 있습니까?Gridview에서 항목을 선택하면 항상 gridview의 맨 위로 돌아갑니다.

<div style="overflow: scroll; width: 100%; height: 350px"> 
<asp:GridView id="GridView1" runat="server" Width="754px" OnRowDataBound="GridView1_RowDataBound"  DataKeyNames="UniqueID" GridLines="None" ForeColor="#333333" EmptyDataText="There are no data records to display." DataSourceID="sdsMapsAdd" CellPadding="4" AutoGenerateColumns="False" AllowSorting="True" AllowPaging="False" OnRowCommand="GridView1_RowCommand" OnSelectedIndexChanged="GridView1_SelectedIndexChanged"> 
<FooterStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" /> 
<Columns> 
<asp:CommandField ShowSelectButton="True" /> 
<asp:BoundField DataField="ID" HeaderText="ID" ReadOnly="True" SortExpression="UniqueID" Visible="false" /> 
<asp:BoundField DataField="Name" HeaderText="Name" ReadOnly="True" SortExpression="SiteName" /> 
<asp:BoundField DataField="Address" HeaderText="Address" SortExpression="Address" /> 
</Columns> 
<RowStyle BackColor="#F7F6F3" ForeColor="#333333" /> 
<EditRowStyle BackColor="#999999" /> 
<SelectedRowStyle BackColor="#E2DED6" Font-Bold="True" ForeColor="#333333" /> 
<PagerStyle BackColor="#284775" ForeColor="White" HorizontalAlign="Center" /> 
<HeaderStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" /> 
<AlternatingRowStyle BackColor="White" ForeColor="#284775" /> 
</asp:GridView> 
</div> 

덕분에 & 감사 관리 경력

+0

... – Pranav

+1

이 링크를 참조를 [A 다시 게시 후있는 gridview 내 사업부의 스크롤 막대의 위치를 ​​유지] 1] [1] : http://stackoverflow.com/questions/12092150/maintain-scroll-bar-position-of-a-div-within-a-gridview-after-a-postback –

답변

0
I have resolved this issue by using the below code. 
<div style="overflow: scroll; width: 100%; height: 350px" id= 'scrollDiv'> 
<script type="text/javascript"> 
var xPos, yPos; 
var prm = Sys.WebForms.PageRequestManager.getInstance(); 
prm.add_beginRequest(BeginRequestHandler); 
prm.add_endRequest(EndRequestHandler); 
function BeginRequestHandler(sender, args) { 
    xPos = $get('scrollDiv').scrollLeft; 
    yPos = $get('scrollDiv').scrollTop; 
} 
function EndRequestHandler(sender, args) { 
    $get('scrollDiv').scrollLeft = xPos; 
    $get('scrollDiv').scrollTop = yPos; 
} 
</script> 

Now I need to fix headers in gridview when I scroll down the gridview then headers are not visible. Please advice 
관련 문제