zoukankan      html  css  js  c++  java
  • .Net Mvc PagedList

    public ActionResult Index(int page = 1,int pageSize = 20)
    {
        var idNumber = Request.Form["txtIdNumber"];
        var applicantName = Request.Form["txtApplicantName"];
        var startDate = Request.Form["txtStartDate"];
        var endDate = Request.Form["txtEndDate"];
    
        int pageIndex = page;
    //int recordCount = 0;
        //var list = bll.GetList(applicantName, idNumber, startDate, endDate, (pageIndex - 1) * pageSize, pageSize, ref recordCount);
        //ViewBag.QueryRecordList = list;
    
        var list = bll.GetList(applicantName, idNumber, startDate, endDate);
    
        IPagedList<QueryRecord> pagedList = list.ToPagedList(pageIndex, pageSize);
    
        return View(pagedList);
    }

    shtml

    @model PagedList.IPagedList<QueryRecord>
    @using PagedList.Mvc;
    
    @{ 
        foreach (var item in Model)
        {
    
            var identify_type = item.IDENTIFY_TYPE.ToString();
            if (item.IDENTIFY_TYPE.ToInt().Equals(0))
            {
                identify_type = "个人";
            }
            else if (item.IDENTIFY_TYPE.ToInt().Equals(100))
            {
                identify_type = "企业";
            }
    
        }
    }
    
    <div>
        总记录  @Model.TotalItemCount 每页 @Model.PageSize 条记录,共 @Model.PageCount 页,当前第 @Model.PageNumber 页
        @Html.PagedListPager(Model, page => Url.Action("Index", new { page }))
        @Html.PagedListPager(Model, page => Url.Action("Index", new { page, pageSize = 100 }),
            new PagedListRenderOptions
            {
                LinkToFirstPageFormat = "首页",
                LinkToNextPageFormat = "下一页",
                LinkToPreviousPageFormat = "上一页",
                LinkToLastPageFormat = "末页",
                MaximumPageNumbersToDisplay = 5,
                DisplayItemSliceAndTotal = false,/*从头到尾显示页码*/
                UlElementClasses = new[] { "pagination" },/*为ul li a 元素添加链接,使用ContainerDivClasses = new[] { "pagination" }替换 UlElementClasses = new[] { "pagination"},也是相同的效果。也可以不要此行代码,因为Bootstrap4与3相比,ul的class名没有变化,li 元素和a 元素加了page-item和page-link的类名。*/
                LiElementClasses = new[] { "page-item" },
                //PageClasses = new[] { "page-link" }
    
            })
    </div>
  • 相关阅读:
    函数声明与表达式
    js数组方法总结
    JavaScript中对象的属性
    微信小程序分辨率的问题
    排序算法---快速排序
    排序算法---归并排序
    iOS 解决1。返回时的黑边问题、2。controller的抖动问题
    UITableViewCell的separator延伸到屏幕两端
    延迟1秒
    动态计算文字的高度
  • 原文地址:https://www.cnblogs.com/hofmann/p/13541046.html
Copyright © 2011-2022 走看看