zoukankan      html  css  js  c++  java
  • Linq的分页

    当前页:<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 () {
    
    
    
    
    
  • 相关阅读:
    C/C++之文件打开方式差别
    C/C++获取文件大小
    dedecms使用
    TCP/IP概念简述
    protobuf新增message报错:类型已存在
    亚马逊MWS开发套路演示
    请求MWS报错401:Access Denied
    敏捷开发
    过滤器和拦截器的区别
    防盗链
  • 原文地址:https://www.cnblogs.com/ntg2/p/13276992.html
Copyright © 2011-2022 走看看