如何将分页添加到Index.cshtml的第一行 [英] How do I add paging to the first line of Index.cshtml

查看:52
本文介绍了如何将分页添加到Index.cshtml的第一行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在NuGet中安装了PageList.Mvc。



如何将它添加到Index.cshtml的第一行?

 @ model IEnumerable <   PagingExample.Models.Table1  >  



HomeController.cs

 使用 PagedList; 
public class HomeController:Controller
{
private testContext db = new testContext();
public 列表< Table1> thistable = new List< Table1>();
public ActionResult Index( int ?page)
{
thistable = db.Data1.ToList();
int pageSize = 3 ;
int pageNumber =(page ?? 1 );
return 查看(thistable.ToPagedList(pageNumber,pageSize));
}
}

解决方案

我不确定问题是什么,但文档很清楚关于用法。它涵盖了不同的用例,可能会回答您的问题。 https://github.com/TroyGoode/PagedList#how-do-i-use-it [ ^ ]。

I have installed PageList.Mvc in NuGet.

How do you add it to the first line of Index.cshtml?

@model IEnumerable<PagingExample.Models.Table1>


HomeController.cs

using PagedList;
    public class HomeController : Controller
    {
        private testContext db = new testContext();
        public List<Table1> thistable = new List<Table1>();
        public ActionResult Index(int? page)
        {
            thistable = db.Data1.ToList();
            int pageSize = 3;
            int pageNumber = (page ?? 1);
            return View(thistable.ToPagedList(pageNumber, pageSize));
        }
    }

解决方案

I'm not sure what the question is, but the documentation is very clear on the usage. It covers the different use cases and might answer your question. https://github.com/TroyGoode/PagedList#how-do-i-use-it[^].


这篇关于如何将分页添加到Index.cshtml的第一行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆