码迷,mamicode.com
首页 > 其他好文 > 详细

Linq的分页

时间:2020-07-10 00:39:40      阅读:71      评论:0      收藏:0      [点我收藏+]

标签:page   contain   each   row   public   code   分页   var   class   

当前页:<span id="currentPage"></span>
总页数:<span id="totalPage"></span>
总条数:<span id="totalCount"></span>
<input id="Button1" type="button" value="首页" onclick="ShowList(1)" />
<input id="Button1" type="button" value="上一页" onclick="ShowList(currentPage-1)" />
<input id="Button1" type="button" value="下一页" onclick="ShowList(currentPage+1)" />
<input id="Button1" type="button" value="尾页" onclick="ShowList(totalPage)" />
public PageModel Get(string YName, int pageSize = 1, int currentPage = 1)
        {
            var list = bll.ShowRowe(YName);
            if (currentPage < 1)
            {
                currentPage = 1;
            }
            if (!string.IsNullOrEmpty(YName))
            {
                list = list.Where(s => s.YName.Contains(YName)).ToList();
            }
            int count = list.Count();
            int page;
            if (count % pageSize == 0)
            {
                page = count / pageSize;
            }
            else
            {
                page = count / pageSize + 1;
            }
            if (currentPage > page)
            {
                currentPage = page;
            }
            var p = new PageModel();
            p.currentPage = currentPage;
            p.totalCount = count;
            p.totalPage = page;
            p.RoweModel = list.Skip((currentPage - 1) * pageSize).Take(pageSize).ToList();
            return p;
        }
 var currentPage = 1;
    var totalPage = 1;
    $(function () {
        ShowList(1);
    });

 function ShowList(page) {
        var obj = {};
        obj.YName = $("#YName").val();
        obj.currentPage = page;
        obj.pageSize = 1;
        $.ajax({
            url: ,
            data: ,
            type: ‘‘,
            dataType: ‘‘,
            success: function (data) {
                currentPage = data.currentPage;
                totalPage = data.totalPage;
                $("#currentPage").text(data.currentPage);
                $("#totalPage").text(data.totalPage);
                $("#totalCount").text(data.totalCount);
                $("#tb").empty();
                $(data.RoweModel).each(function () {

 


Linq的分页

标签:page   contain   each   row   public   code   分页   var   class   

原文地址:https://www.cnblogs.com/ntg2/p/13276992.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!