仅在选择了gridview的新页面时滚动到顶部 [英] Scroll to top only when a new page of a gridview is selected
问题描述
我有一个UpdatePanel,在ContentTemplate中,我在div中有一个gridview,它位于一个面板中:
Hi,
I have an UpdatePanel and, in the ContentTemplate, I have a gridview inside a div, that is inside a panel:
<asp:Panel ID="pnl" runat="server">
<div style="overflow: auto; width: 1354px; height: 420px;" id="divScroll">
<asp:GridView ID="gv" runat="server" ...>
</asp:GridView>
</div>
</asp:Panel>
div是一个Id,因为我想在用户选择gridview的一行时保存垂直滚动条位置(我在维护GridView滚动位置和标题中使用了javascript在UpdatePanel内部文章。
我现在关注的是:当网格被分页并且用户选择页面时,如何重置div的滚动条的垂直位置?现在,位置保持在网格的底部,这是页面选择的位置;我希望用户可以更改页面并开始从网格新页面的第一行查看网格内容。
我试图处理Gridview.PageIndexChanged事件,但是我不知道该怎么做......有什么想法吗?
提前致谢!
The div ha an Id because I want to save the vertical scrollbar position when the user selects a row of the gridview (I used a javascript as in "Maintain GridView Scroll Position and Header Inside UpdatePanel" article).
My concern is now the following: when the grid is paged and the user selects a page, how can I reset the vertical position of the scrollbar of the div? Now, the position remains at the bottom of the grid, that''s where the page selection is; I''d like that the user could change the page and start viewing the grid content from the first line of the new page of the grid.
I tried to work on the Gridview.PageIndexChanged event, but I don''t know what to do exactly... Any ideas?
Thanks in advance!
推荐答案
在Gridview.PageIndexChanged上event,添加此代码
On the Gridview.PageIndexChanged event, add this code
pnl.Focus();
这篇关于仅在选择了gridview的新页面时滚动到顶部的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!