zoukankan      html  css  js  c++  java
  • vs分页

    --api

    public PageInfor Get(string name = "", string pricemin = "", string pricemax = "", int type = 0,string band = "", int CurrentPage = 1, int PageSize = 5)
    {
    var list = udal.MenberShow();
    if (!string.IsNullOrEmpty(name))
    {
    list = list.Where(s => s.MenberName.Contains(name)).ToList();
    }
    if (pricemin != "" && pricemax != "")
    {
    list = list.Where(s => s.MenberCard >= Convert.ToInt32(pricemin) && s.MenberCard <= Convert.ToInt32(pricemax)).ToList();
    }
    if (!string.IsNullOrEmpty(band))
    {
    list = list.Where(s => s.MenberTypeId.Contains(band)).ToList();
    }
    if (type != 0)
    {
    list = list.Where(s => s.Integral == type).ToList();
    }
    //实例化分页类
    var p = new PageInfor();
    //总记录数
    p.TotalCount = list.Count();
    //计算总页数
    if (p.TotalCount == 0)
    {
    p.TotalPage = 1;
    }
    else if (p.TotalCount % PageSize == 0)
    {
    p.TotalPage = p.TotalCount / PageSize;
    }
    else
    {
    p.TotalPage = (p.TotalCount / PageSize) + 1;
    }
    //纠正当前页不正确的值
    if (CurrentPage < 1)
    {
    CurrentPage = 1;
    }
    if (CurrentPage > p.TotalPage)
    {
    CurrentPage = p.TotalPage;
    }
    p.shopModels = list.Skip(PageSize * (CurrentPage - 1)).Take(PageSize).ToList();
    p.CurrentPage = CurrentPage;
    return p;
    }

    --mvc

    <table class=" table-bordered table">
    <tr>
    <td>总记录数<span id="TotalCount"></span>条</td>
    <td>总共<span id="TotalPage"></span>页</td>
    <td>当前第<span id="CurrentPage"></span>页</td>
    <td><a href="javascript:;" onclick="MenberShow(1)">首页</a></td>
    <td><a href="javascript:;" onclick="MenberShow(CurrentPage-1)">上一页</a></td>
    <td><a href="javascript:;" onclick="MenberShow(CurrentPage+1)">下一页</a></td>
    <td><a href="javascript:;" onclick="MenberShow(TotalPage)">尾页</a></td>
    </tr>
    </table>

    function MenberShow(page) {
    var asd = {};
    asd.SettingGrade = $("#band").val();
    asd.MenberName = $("#name").val();
    $.ajax({
    url: 'https://localhost:44329/api/Stu/Get',
    type: 'get',
    dataType: 'json',
    data: {
    name: $("#name").val(), type: $("#type").val(), band: $("#band").val(), pricemin: $("#Pricemin").val(), pricemax: $("#Pricemax").val(), CurrentPage: page
    },
    success: function (d) {
    $("#TotalCount").text(d.TotalCount)
    $("#TotalPage").text(d.TotalPage)
    $("#CurrentPage").text(d.CurrentPage)
    //最大页
    TotalPage = d.TotalPage;
    //当前页
    CurrentPage = d.CurrentPage;
    //清空表格
    $("#td").empty();
    $(d.shopModels).each(function () {
    var line = '<tr>'
    + '<td>' + this.MenberId + '</td>'
    + '<td>' + this.MenberCard + '</td>'
    + '<td>' + this.SettingGrade + '</td>'
    + '<td>' + this.MenberType + '</td>'
    + '<td>' + this.MenberName + '</td>'
    + '<td>' + this.MenberPhone + '</td>'
    + '<td>' + this.Cumulative + '</td>'
    + '<td>' + this.Storage + '</td>'
    + '<td>' + this.Integral + '</td>'
    + '<td>' + this.Activate + '</td>'
    + '<td>' + this.Expiration + '</td>'
    + '<td>' + "<a onclick=MenberUpt(" + this.MenberId + ")>" + (this.Condition ? "启用" : "禁用") + "</a>" + '</td>'
    + '<td>' + '<a data-toggle="modal" data-target="#myModal4" onclick=GetId(' + this.MenberId + ')>操作</a>' + '</td>'
    + '</tr>'
    $("#td").append(line);
    })
    }
    })
    }

  • 相关阅读:
    JAVA中线程同步的方法(4种)汇总
    java
    指定的元素已经是另一个元素的逻辑子元素。请先将其断开连接。(解决问题总结)
    无法将类型为“System.Windows.Controls.SelectedItemCollection”的对象强制转换为类型“System.Collections.Generic.IList`1
    foreach---集合已修改;可能无法执行枚举操作。
    WPF_View中控件使用单例ViewModel
    判断s2是否能够被通过s1做循环移位(rotate)得到的字符串是否包含
    多列转1列 SqlServer 实现oracle10g的 wmsys.wm_concat()--for xml path('')
    异步对象(XMLHttpRequest)的帮助脚本
    在vs2010使用EF出现CS0012: 类型“System.Data.Objects.DataClasses.EntityObject”在未被引用的程序集中定义
  • 原文地址:https://www.cnblogs.com/zhang2000/p/13253831.html
Copyright © 2011-2022 走看看