0

我正在使用GridView控件并且分页不起作用。在单步执行代码时,当我单击要转到的页面时,会调用该事件,但从未调用过Page_Load我的事件。OnPageIndexChanging

<asp:GridView ID="FaxGrid" 
                        runat="server"                                         
                        BackColor="#FFFFFF"
                        HeaderStyle-BackColor="#CEDFF2"
                        HeaderStyle-ForeColor="#316495"
                        HeaderStyle-Font-Bold="true"
                        BorderColor="#CEDFF2" 
                        AutoGenerateColumns="false" 
                        OnRowCommand="FaxGridRowCommandHandler" 
                        DataKeyNames="file_id" 
                        AllowPaging="true" 
                        PageSize="10" 
                        PagerSettings-Mode="NumericFirstLast" 
                        OnPageIndexChanging="FaxGrid_PageIndexChanging" 
                        Height="222" 
                        EmptyDataText="No faxes found." 
                        HeaderStyle-Height="35" Width="1470" >
                            <Columns>
                                <asp:BoundField HeaderText="File Name" DataField="file_friendly_name" HeaderStyle-HorizontalAlign="Center" ItemStyle-HorizontalAlign="Center" HeaderStyle-Width="125"></asp:BoundField>
                                <asp:BoundField HeaderText="Dept. Name" DataField="department_name" HeaderStyle-HorizontalAlign="Center" ItemStyle-HorizontalAlign="Center" HeaderStyle-Width="125"></asp:BoundField>
                                <asp:BoundField HeaderText="Processed" DataField="processed" HeaderStyle-HorizontalAlign="Center" ItemStyle-HorizontalAlign="Center" HeaderStyle-Width="50"></asp:BoundField>
                                <asp:BoundField HeaderText="First Name" DataField="firstname" HeaderStyle-HorizontalAlign="Center" ItemStyle-HorizontalAlign="Center" HeaderStyle-Width="125"></asp:BoundField>
                                <asp:BoundField HeaderText="Last Name" DataField="lastname" HeaderStyle-HorizontalAlign="Center" ItemStyle-HorizontalAlign="Center" HeaderStyle-Width="125"></asp:BoundField>
                                <asp:BoundField HeaderText="DOB" DataField="dob" HeaderStyle-HorizontalAlign="Center" ItemStyle-HorizontalAlign="Center" HeaderStyle-Width="75"></asp:BoundField>
                                <asp:BoundField HeaderText="Ref. Physician" DataField="referringPhy" HeaderStyle-HorizontalAlign="Center" ItemStyle-HorizontalAlign="Center" HeaderStyle-Width="125"></asp:BoundField>
                                <asp:BoundField HeaderText="Reported" DataField="reported" HeaderStyle-HorizontalAlign="Center" ItemStyle-HorizontalAlign="Center" HeaderStyle-Width="75"></asp:BoundField>
                                <asp:BoundField HeaderText="Reported On" DataField="reportedon" HeaderStyle-HorizontalAlign="Center" ItemStyle-HorizontalAlign="Center" HeaderStyle-Width="125"></asp:BoundField>
                                <asp:BoundField HeaderText="Job Status" DataField="description" HeaderStyle-HorizontalAlign="Center" ItemStyle-HorizontalAlign="Center" HeaderStyle-Width="125"></asp:BoundField>
                                <asp:TemplateField HeaderText="Fax Options" HeaderStyle-Width="145">
                                    <ItemTemplate>
                                        <asp:Button ID="btnCancel" runat="server" CommandName="CancelFax" CommandArgument='<%# Container.DataItemIndex %>' ToolTip="Cancel and delete fax" Text="Cancel" />
                                        <asp:Button ID="btnResend" runat="server" CommandName="Resend" CommandArgument='<%# Container.DataItemIndex %>' ToolTip="Resend an existing fax." Text="Resend" />
                                        <asp:Button ID="btnSendAsNew" runat="server" CommandName="SendAsNew" CommandArgument='<%# Container.DataItemIndex %>' ToolTip="Send as a new fax." Text="Send as New" />
                                    </ItemTemplate>                
                                </asp:TemplateField>
                            </Columns>
            </asp:GridView>

这是我的文件后面的代码:

protected void Page_Load(object sender, EventArgs e)
{
    if (Page.IsPostBack == false)
    {
        this.sqlObj = new SqlServer(ConfigurationManager.ConnectionStrings["PdfReceiverConnectionString"].ToString());
        this.populateFaxGrid();
    }
}

protected void FaxGrid_PageIndexChanging(object sender, GridViewPageEventArgs e)
{
    this.FaxGrid.PageIndex = e.NewPageIndex;

    this.FaxGrid.DataSource = this.Session["Faxes"];

    this.FaxGrid.DataBind();

}

我感谢任何帮助。

4

1 回答 1

0

您的代码似乎没问题,有时复制粘贴代码无法正确绑定事件,这种情况发生在我身上很多次。删除事件并再次绑定。

于 2013-07-12T15:50:58.800 回答