这是一个奇怪的问题。我在下拉列表 selectedindexchanged 中设置 gridview 的页面大小,这是我的 gridview 寻呼机模板。这是我的html源代码
<PagerTemplate>
<div class="grid-footer">
<div class="gridfooter_size"> <asp:DropDownList ID="pageSize2" runat="server" AutoPostBack="true"
onselectedindexchanged="pageSize2_SelectedIndexChanged">
<asp:ListItem Value="10" Selected="True">10</asp:ListItem>
<asp:ListItem Value="25">25</asp:ListItem>
<asp:ListItem Value="50">50</asp:ListItem>
<asp:ListItem Value="100">100</asp:ListItem>
</asp:DropDownList>
</div>
<div class="gridfooter_info">
<asp:Label ID="lblSummary" runat="server"></asp:Label>
</div>
<div class="gridfooter_paginate">
<asp:LinkButton ID="lnkFirstbnt" runat="server" CommandName="Page" CssClass="pagerclass-nxt"
CausesValidation="false" CommandArgument="First">First</asp:LinkButton>
<asp:LinkButton ID="lnkPrevbnt" runat="server" CommandName="Page" CssClass="pagerclass-prev"
CausesValidation="false" CommandArgument="Prev">Previous</asp:LinkButton>
<asp:Label ID="CurrentPage" CssClass="pagerclass-number" Visible="false" runat="server"
Text="Label"></asp:Label>
<asp:LinkButton ID="lnkNextbnt" runat="server" CommandName="Page" CssClass="pagerclass-next"
CausesValidation="false" CommandArgument="Next">Next</asp:LinkButton>
<asp:LinkButton ID="lnkLastbnt" runat="server" CommandName="Page" CssClass="pagerclass-last"
CausesValidation="false" CommandArgument="Last">Last</asp:LinkButton>
</div>
</div>
</PagerTemplate>
这是我背后的代码
Protected Sub pageSize2_SelectedIndexChanged(sender As Object, e As System.EventArgs)
Dim gvr2 As GridViewRow = GridView2.BottomPagerRow
Dim ddPageSize2 As DropDownList = DirectCast(gvr2.Cells(0).FindControl("pageSize2"), DropDownList)
GridView2.PageSize = Convert.ToInt32(ddPageSize2.SelectedValue)
Call GetDataTables2()
End Sub
发生回发时,pageSize2_SelectedIndexChanged
将为下拉列表的所有选定值触发事件,但页面未呈现。它从 pageSize2_SelectedIndexChanged 事件Call GetDataTables2()
方法跳转。如果下拉列表选择的值为10,那么页面正在渲染,很奇怪。可能是什么问题,请提出解决方案