日期:2014-05-17  浏览次数:20532 次

GridView的PageIndexChanging事件为什么没有被触发?
自定义导航页: 
  <PagerTemplate>
  <table width="100%">
  <tr>
  <td width="100%" align="left">
  <asp:Label ID="CurrentPageLabel" ForeColor="Blue" runat="server" />
  &nbsp;&nbsp;&nbsp;&nbsp;
  <asp:Label ID="MessageLabel" ForeColor="Blue" Text="页码:" runat="server" />
  <asp:DropDownList ID="PageDropDownList" AutoPostBack="true" OnSelectedIndexChanged="PageDropDownList_SelectedIndexChanged" 
  runat="server" />
  &nbsp;&nbsp;&nbsp;&nbsp;
  <asp:LinkButton ID="linkBtnFirst" runat="server" CommandName="Page" CommandArgument="First" >首页</asp:LinkButton>
  &nbsp;&nbsp;
  <asp:LinkButton ID="linkBtnPrev" runat="server" CommandName="Page" CommandArgument="Prev">上一页</asp:LinkButton>
  &nbsp;&nbsp;
  <asp:LinkButton ID="linkBtnNext" runat="server" CommandName="Page" CommandArgument="Next">下一页</asp:LinkButton>
  &nbsp;&nbsp;
  <asp:LinkButton ID="linkBtnLast" runat="server" CommandName="Page" CommandArgument="Last">尾页</asp:LinkButton>
  </td>
   
  </tr>
  </table>
  </PagerTemplate>

 后台代码:
  protected void GridViewResult_PageIndexChanging(object sender, GridViewPageEventArgs e)
  {
  GridViewResult.PageIndex = e.NewPageIndex;
  // this.CurrentPage = e.NewPageIndex;//保存当前页码
  BindGrid();
  }

点击“上一页”“下一页”都OK,可一点击“尾页”,(点击“尾页也是正确的,从那以后点击就当行错误了”)整个导航页就出现错误,设断点查了原因是因为没有进入PageIndexChanging事件,可之前的进入可以,为什么点击尾页后就不进去了呢?



------解决方案--------------------
那你要看点击尾页后发生了什么?
------解决方案--------------------
你调试看看
------解决方案--------------------
报的什么错误