我有两个更新面板,其中一个包含一个网格视图。问题是分页仅在第一次正常工作。
这是标记:
<asp:UpdatePanel ID="upAnswers" runat="server" UpdateMode="Conditional" ChildrenAsTriggers="true">
<ContentTemplate>
<asp:GridView ID="gvAnswers" runat="server" CssClass="gv" Width="100%" ShowHeader="false" AllowPaging="True" PageSize="2" EnableSortingAndPagingCallbacks="true" OnPageIndexChanging="gvAnswers_PageIndexChanging" AutoGenerateColumns="False" AlternatingRowStyle-BackColor="#eee">
<Columns>
<asp:TemplateField HeaderText="Questions" ShowHeader="False">
<ItemTemplate>
<asp:Label ID="lblQuestions" onclick=<%# Eval("FaqID", "$('.lblAnswers_{0}').toggle('fast')") %> CssClass="block" runat="server" Text='<%# Eval("Title") %>'></asp:Label>
<asp:Panel ID="pnlS1" runat="server" CssClass='<%# Eval("FaqID", "lblAnswers_{0}") %>' style="display: none;">
<asp:Label ID="Label1" runat="server" Text='<%# Eval("Question") %>' CssClass="block bold"></asp:Label>
<asp:Label ID="lblAnswers" runat="server" Text='<%# Eval("Answer") %>'></asp:Label>
</asp:Panel>
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
</ContentTemplate>
</asp:UpdatePanel>
<asp:UpdateProgress ID="upgAnswers" runat="server" AssociatedUpdatePanelID="upAnswers" DisplayAfter="300">
<ProgressTemplate>
<div id="uiBlock" class="uiBlock">
</div>
</ProgressTemplate>
</asp:UpdateProgress>
以及背后的代码:
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
GetAnsweredPublicFAQs();
}
}
protected void GetAnsweredPublicFAQs()
{
DataSet ds = cFAQs.getAnsweredPublicFAQs();
gvAnswers.DataSource = ds;
gvAnswers.DataBind();
}
protected void gvAnswers_PageIndexChanging(object sender, GridViewPageEventArgs e)
{
gvAnswers.PageIndex = e.NewPageIndex;
GetAnsweredPublicFAQs();
gvAnswers.DataBind();
upAnswers.Update();
}
作为参考,我使用 ASP.NET 4.0 C#。
任何帮助将不胜感激。
问候, 卡多