我的页面上有一个gridview,如下所示
<div style="overflow-x:scroll; width:100%; height:255px">
<asp:GridView ID="GridView1" runat="server" CellPadding="4" ForeColor="#333333" GridLines="Horizontal"
BorderStyle="Solid" BorderColor="Black" AllowPaging="false" PageSize="4" OnPageIndexChanging="GridView1_PageIndexChanging" Height="235px"
width="90%" OnRowDataBound="GridView1_RowDataBound" OnSelectedIndexChanged="GridView1_SelectedIndexChanged" AutoGenerateColumns="false"
RowStyle-Height="37px" HeaderStyle-Height="40px" FooterStyle-Height="40px">
<Columns>
<asp:BoundField HeaderText="ID" DataField="UserID" />
<asp:BoundField HeaderText="User Name" DataField="UserName" HeaderStyle-HorizontalAlign="Center"/>
<asp:BoundField HeaderText="User Role" DataField="UserRoleName"/>
</Columns>
<AlternatingRowStyle BackColor="White" ForeColor="#284775" />
<EditRowStyle BackColor="#999999" />
<FooterStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
<HeaderStyle BackColor="#2e85c2" Font-Bold="True" ForeColor="White" HorizontalAlign="Center" VerticalAlign="Middle" />
<PagerStyle BackColor="#2e85c2" ForeColor="White" HorizontalAlign="Center" VerticalAlign="Bottom" />
<RowStyle BackColor="#F7F6F3" ForeColor="#333333" />
<SelectedRowStyle BackColor="#E2DED6" Font-Bold="True" ForeColor="#333333" />
<SortedAscendingCellStyle BackColor="#E9E7E2" />
<SortedAscendingHeaderStyle BackColor="#506C8C" />
<SortedDescendingCellStyle BackColor="#FFFDF8" />
<SortedDescendingHeaderStyle BackColor="#6F8DAE" />
</asp:GridView>
</div>
这工作正常,下面的 selectedindexchanged 方法也是如此
protected void GridView1_SelectedIndexChanged(Object sender, EventArgs e)
{
GridViewRow row = GridView1.SelectedRow;
int sd = int.Parse(row.Cells[0].Text);
removeUserButton.Enabled = true;
GridView1.Focus();
}
但是当我从 gridview 的底部选择一个项目时,它会重置滚动条,如果不向下滚动,您将看不到选择的内容。有没有办法防止页面上的额外滚动?