• MVC中,加入的一个aspx页面用到AspNetPager控件处理办法


    今天项目遇到了如题所示的问题,按照官方的案例介绍做分页,简直要奔溃了,

    使用URL重写,但是page总是1,根本不跳,

    不使用URL重写,又出现,第一页是 http://aa.com/view_aspx/pagetest.aspx?page=1,点击第二页就变成http://aa.com/pagetest.aspx?page=2 这样路径不对

    最近解决办法

    首先是页面控件部分,特别注意红色部分,那个page一定要用page ,用别的没有用的

    <webdiyer:AspNetPager ID="AspNetPager1" runat="server" UrlPaging="True" UrlPageSizeName="page" PageIndexBoxType="DropDownList"
    HorizontalAlign="left" PageSize="5"
    OnPageChanged="AspNetPager1_PageChanged" CssClass="pages"
    CurrentPageButtonClass="cpb" FirstPageText="首页" LastPageText="最后一页"
    NextPageText="下一页" PrevPageText="上一页" EnableUrlRewriting="true" UrlRewritePattern="/View_Aspx/EvalInfoList.aspx?page={0}">

    然后后台里面:ViewState["currentPageId"] 保存他的页码值

    if (Request.QueryString["page"] != null && !string.IsNullOrEmpty(Request.QueryString["page"].ToString()))
    {
    int currentPageId = Convert.ToInt32(Request.QueryString["page"].ToString());
    ViewState["currentPageId"] = currentPageId;
    }
    else
    {
    ViewState["currentPageId"] = 1;
    }

    AspNetPager1.CurrentPageIndex = Convert.ToInt32(ViewState["currentPageId"]);
    AspNetPager1.RecordCount = evalservice.GetEvaltionListCount(sitelangId);

    if (!IsPostBack)
    {
    BindData(1);
    }

    //分页事件里面这样写:

    protected void AspNetPager1_PageChanged(object src, EventArgs e)
    {
    BindData(Convert.ToInt32(ViewState["currentPageId"]));
    }

    目前来讲测试过几页没有问题的

  • 相关阅读:
    Ensure that you have installed a JDK (not just a JRE) and configured your JAVA_HOME system variable
    调试bug 技巧
    调试bug 技巧
    调试bug 技巧
    调试技巧之 找准调试点
    调试技巧之 找准调试点
    调试技巧之 找准调试点
    adnroid 打包问题 :compileReleaseJavaWithJavac
    线程等待
    LinkedList源码解析(jdk1.8)
  • 原文地址:https://www.cnblogs.com/angels/p/4572050.html
Copyright © 2020-2023  润新知