我在更新面板中放置了两个网格视图。它们都允许分页显示数据。
我的.aspx
页面代码是:
<asp:UpdatePanel ID="upMaster" runat="server" >
<ContentTemplate>
<div class="TeamBox">
<asp:GridView ID="MangersGrid" GridLines="None" AutoGenerateColumns="false" AllowPaging="true" PageSize="10" runat="server" OnPageIndexChanging="MangersGrid_PageIndexChanging">
<Columns>
<asp:BoundField DataField="Name" HeaderText="Team Managers" />
</Columns>
</asp:GridView>
</div>
<div class="TeamBox">
<asp:GridView ID="MembersGrid" AllowPaging="true" GridLines="None" AutoGenerateColumns="false" runat="server" PageSize="10" OnPageIndexChanging="MembersGrid_PageIndexChanging">
<Columns>
<asp:BoundField DataField="Name" HeaderText="Team Members" />
</Columns>
</asp:GridView>
</div>
</ContentTemplate>
</asp:UpdatePanel>
我的代码.cs
是:
protected void Page_Load(object sender, EventArgs e) {
DoProcess();
}
void DoProcess() {
// logic to get data table records one for each.
MangersGrid.DataSource = dtManagers;
MangersGrid.DataBind();
MembersGrid.DataSource = dtNativeMembers;
MembersGrid.DataBind();
upMaster.Update();
}
void MangersGrid_PageIndexChanging(object sender, System.Web.UI.WebControls.GridViewPageEventArgs e)
{
MangersGrid.PageIndex = e.NewPageIndex;
DoProcess();
}
// Members Gridview page index change event
void MembersGrid_PageIndexChanging(object sender, System.Web.UI.WebControls.GridViewPageEventArgs e)
{
MembersGrid.PageIndex = e.NewPageIndex;
DoProcess();
}
页面控件显示页数,但它只呈现第一页。如果我单击下一页,它不会做任何事情。
我错过了什么?