我对pageIndexChanging方法有疑问。 我的代码没有进入pageindexchanging方法。 我已经添加了updatePanel,但它仍然无法正常工作。 你有什么想法吗?
我的代码是
<asp:UpdatePanel ID="updatePanel" runat="server">
<ContentTemplate>
<asp:GridView ID="grdEmp" runat="server" AllowSorting="True" EmptyDataText="No records found"
CssClass="table table-striped table-bordered" RowStyle-CssClass="rowHover" ShowHeader="true" OnRowCommand="grdEmp_RowCommand"
AutoGenerateColumns="False"
AllowPaging="True"
OnPageIndexChanging="grdEmp_PageIndexChanging"
PageSize="20"
CellPadding="2" ForeColor="#333333"
GridLines="None" Width="100%">
<AlternatingRowStyle BackColor="White" ForeColor="#284775" />
<Columns>
<asp:BoundField HeaderText="Movie" DataField="name" ItemStyle-HorizontalAlign="Center" ItemStyle-VerticalAlign="Middle" />
<asp:BoundField HeaderText="Director" DataField="director" ItemStyle-HorizontalAlign="Center" ItemStyle-VerticalAlign="Middle" />
<asp:BoundField HeaderText="Genre" DataField="genre" ItemStyle-HorizontalAlign="Center" ItemStyle-VerticalAlign="Middle" />
<asp:BoundField HeaderText="Year" DataField="year" ItemStyle-HorizontalAlign="Center" ItemStyle-VerticalAlign="Middle" />
<asp:ButtonField HeaderText="" ItemStyle-HorizontalAlign="Center" ItemStyle-VerticalAlign="Middle" ButtonType="Button" ControlStyle-CssClass="btn btn-default" Text="Like" CommandName="like" />
</Columns>
<EditRowStyle BackColor="#999999" />
<FooterStyle BackColor="#ffffff" Font-Bold="True" ForeColor="Red" />
<HeaderStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
<PagerStyle BackColor="#284775" ForeColor="White" HorizontalAlign="Center" />
<RowStyle CssClass="rowHover" BackColor="#F7F6F3" ForeColor="#333333"></RowStyle>
<SelectedRowStyle BackColor="#E2DED6" Font-Bold="True" ForeColor="#333333" />
<SortedAscendingCellStyle BackColor="#E9E7E2" />
<SortedAscendingHeaderStyle BackColor="#506C8C" />
<SortedDescendingCellStyle BackColor="#FFFDF8" />
<SortedDescendingHeaderStyle BackColor="#6F8DAE" />
<EmptyDataRowStyle Width="550px" ForeColor="Red" Font-Bold="true"
HorizontalAlign="Center" />
</asp:GridView>
</ContentTemplate>
</asp:UpdatePanel>
protected void grdEmp_PageIndexChanging(object sender,
GridViewPageEventArgs e)
{
grdEmp.PageIndex = e.NewPageIndex;
BindMoviesGrid();
}
答案 0 :(得分:0)
您可以在Update Update面板上指定UpdateMode,然后使用PostBackTrigger或AsyncPostBackTrigger指定触发器部分。
<asp:UpdatePanel ID="upnlReg" runat="server" UpdateMode="Conditional">
<ContentTemplate>
</ContentTemplate>
<Triggers>
<asp:PostBackTrigger ControlID="grdEmp" />
</Triggers>
</asp:UpdatePanel>