在Gridview中选择一个项目后,它总是返回到gridview的顶部 [英] After selecting an item in Gridview it always returns to the top of the gridview
本文介绍了在Gridview中选择一个项目后,它总是返回到gridview的顶部的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有GridView控件。代码如下。它允许行选择。问题是,当我向下滚动这个GridView并选择一些底行时,会发生选择,但整个GridView会滚动回顶部。有谁知道如何避免这种情况?
I've got GridView control. code is given below. It allows row selection. The problem is, when I scroll down this GridView and select some of the bottom rows the selection occurs, but whole GridView is scrolling back to top. Does anyone know how to avoid this?
<div id="grd1" 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>
推荐答案
如果您使用的是异步回发(更新面板等)..那么请看一下。 。
维护-scroll-position-asynchronous-asynchronous-postback.aspx [ ^ ]
还有这个..
http://www.4guysfromrolla.com/articles/111704-1.aspx [< a href =http://www.4guysfromrolla.com/articles/111704-1.aspx target =_ blanktitle =New Window> ^ ]
If you are using asynchronous postback (update panel etc.)..then have a look at ..
maintain-scroll-position-after-asynchronous-postback.aspx[^]
and also this..
http://www.4guysfromrolla.com/articles/111704-1.aspx[^]
请查看CP上的以下文章:
< a href =http://www.codeproject.com/Articles/29634/Scroll-Gridview-while-Maintaining-Scroll-Position>滚动网格视图,同时维护滚动位置 [ ^ ]
< br $>
祝你好运,
OI
Please have a look at the following article on CP:
Scroll Gridview while Maintaining Scroll Position[^]
Good luck,
OI
你好OI,
我已经使用此代码在长时间搜索后修复标题。请参阅此代码链接。
[ ^ ]
请问您如何保持滚动位置使用此代码。?
谢谢&问候
Care Career
Hi OI,
I have already used this code for fixing the header after long search. Please see this code link.
[^]
Could you please advice how would I maintain scroll position using this code.?
Thanks & Regards
Care Career
这篇关于在Gridview中选择一个项目后,它总是返回到gridview的顶部的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文