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);
    })
    }
    })
    }

  • 相关阅读:
    0_Simple__simplePrintf
    0_Simple__simplePitchLinearTexture
    0_Simple__simpleP2P
    0_Simple__simpleOccupancy
    0_Simple__MultiGPU
    0_Simple__simpleMultiCopy
    0_Simple__simpleMPI
    0_Simple__simpleLayeredTexture
    0_Simple__simpleCubemapTexture
    0_Simple__simpleCooperativeGroups
  • 原文地址:https://www.cnblogs.com/zhang2000/p/13253831.html
Copyright © 2011-2022 走看看