我正在使用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();
}
我感谢任何帮助。
答案 0 :(得分:0)
你的代码似乎没事,有时复制粘贴代码并没有正确绑定事件,这发生在我身上很多次。删除事件并再次绑定它。