简体   繁体   中英

Href attributes are empty in Pagedlist Pagination Links

PagedListPager method is generating Pagination Links (Anchor Tags) but their href attributes are Empty/Null. See the Image

在此处输入图片说明

Code in View

@Html.PagedListPager(Model, page => Url.Action("Orders", new { page, size = Model.PageSize }), new PagedListRenderOptions() { Display = PagedListDisplayMode.IfNeeded })

Namespaces are added

@using PagedList;
@using PagedList.Mvc;
@model IPagedList<eRepository.Models.Orders>

Controller Method

public ActionResult Orders(int? page)
        {
            using (_context db = new _context())
            {
                return View(db.userorders.Where(s => s.status == 1).OrderBy(d => d.cdate).ToPagedList(page ?? 1, 10));
            }
        }

You should do something like this:

Controller:

public ActionResult Orders(int? page)
   {
       var model = db.Orders.ToList();
       int pageSize = 3;
       int pageNumber = (page ?? 1);
       return View(model.ToPagedList(pageNumber, pageSize));
   }

View:

@using PagedList;
@using PagedList.Mvc

@model IPagedList<Store.Models.Orders>


@Html.PagedListPager(Model, page => Url.Action("Index", new { page }), new PagedListRenderOptions() { Display = PagedListDisplayMode.IfNeeded })

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM