0

我有一个带有 C# 的 ASPX 应用程序。在一个页面中,我有一个带有分页的 gridview(我添加了 allowpaging="true",PageSize="2")。在 aspx 文件中:

  <table>
    <tr>
        <td>
            <asp:GridView ID="grdClientList" runat="server" OnRowCreated="grdClientList_RowCreated"
                OnRowDataBound="grdClientList_RowDataBound" AutoGenerateColumns="False" 
                DataSourceID="ODSClientList" DataKeyNames="ID"
                AllowPaging="true" AllowSorting="true" PageSize="2"
                OnPageIndexChanging="grdClientList_PageIndexChanging">
                <Columns>
                    <asp:BoundField DataField="ID" HeaderText="ID" SortExpression="ID" 
                        ItemStyle-CssClass="hidden"  HeaderStyle-CssClass="hidden" />
                    <asp:BoundField DataField="Name" HeaderText="<%$Resources:HRWebApplicationResources,ClientsList_ColName %>" SortExpression="Name" 
                         ControlStyle-Width="150px" ItemStyle-Width="150px"/>
                    <asp:BoundField DataField="Address" HeaderText="<%$Resources:HRWebApplicationResources,ClientsList_ColAddress %>" SortExpression="Address" 
                        ControlStyle-Width="280px" ItemStyle-Width="280px"/>
                    <asp:BoundField DataField="Contact" HeaderText="<%$Resources:HRWebApplicationResources,ClientsList_ColContact %>" SortExpression="Contact"
                         ControlStyle-Width="100px" ItemStyle-Width="100px"  />
                    <asp:BoundField DataField="Telephone" HeaderText="<%$Resources:HRWebApplicationResources,ClientsList_ColTelephone %>" SortExpression="Telephone" 
                         ControlStyle-Width="100px" ItemStyle-Width="100px" />
                    <asp:BoundField DataField="Email" HeaderText="<%$Resources:HRWebApplicationResources,ClientsList_ColEmail %>" SortExpression="Email" 
                        ControlStyle-Width="130px" ItemStyle-Width="130px" />
                    <asp:HyperLinkField 
                          HeaderText="<%$Resources:HRWebApplicationResources,AllPages_Actions%>" ShowHeader="True" Text="Edit"
                          DataNavigateUrlFormatString="~/Client/ClientDetail.aspx?Id={0}" 
                          DataNavigateUrlFields="ID" ControlStyle-Width="70px" ItemStyle-Width="70px"/>
                </Columns>
            </asp:GridView>
        </td>
    </tr>
</table>

 <asp:ObjectDataSource ID="ODSClientList" runat="server" OldValuesParameterFormatString="{0}"
    SelectMethod="GetAllClientsByFilter" TypeName="HRWebApplication.AppCode.ManageList">
    <SelectParameters>
       <asp:ControlParameter ControlID="txtSearchName" Name="p_strName" PropertyName="Text" Type="String" />
       <asp:ControlParameter ControlID="txtSearchAddress" Name="p_strAddress" PropertyName="Text" Type="String" />
       <asp:ControlParameter ControlID="txtSearchContact" Name="p_strContact" PropertyName="Text" Type="String" />
       <asp:ControlParameter ControlID="txtSearchTelephone" Name="p_strTelephone" PropertyName="Text" Type="String" />
       <asp:ControlParameter ControlID="txtSearchEmail" Name="p_strEmail" PropertyName="Text" Type="String" />
    </SelectParameters>
</asp:ObjectDataSource>

在cs文件中:

  protected void grdClientList_PageIndexChanging(object sender, GridViewPageEventArgs e)
    {
        grdClientList.PageIndex = e.NewPageIndex;
        grdClientList.DataBind();
    }

当我单击第二个、第三个等页面时,我的应用程序没有执行任何操作。没有进入“grdClientList_PageIndexChanging”事件。有人知道为什么吗?

4

1 回答 1

0

也许尝试 PageIndexChanged 而不是 PageIndexChanging?

于 2013-01-30T13:55:32.827 回答