zoukankan      html  css  js  c++  java
  • c#分页增加顺序编号方法代码


    //顺序
    public static List<TModel<T>> ConvertList<T>(int pg, int pagesize, List<T> list) { List<TModel<T>> models = new List<TModel<T>>(); int n = 0; int x = pg * pagesize; if (list.Count < pagesize) { x = pg * pagesize - pagesize + list.Count; } for (int i = (pg - 1) * pagesize; i < x; i++) { TModel<T> model = new TModel<T>(); int m = i + 1; model.keyid = m; model.propert = list[n]; models.Add(model); n++; } return models; }

     
    //编号顺序倒序
    public List<TModel<T>> ResvertList<T>(int pg, int pagesize, List<T> list, int pagenum) { List<TModel<T>> models = new List<TModel<T>>(); int n = 0; int x = pg * pagesize; if (list.Count < pagesize) { x = pg * pagesize - pagesize + list.Count; } for (int i = (pg - 1) * pagesize; i < x; i++) { TModel<T> model = new TModel<T>(); int c = pagenum - i; model.keyid = c; model.propert = list[n]; models.Add(model); n++; } return models; }
    
    
    public class TModel<T>
            {
                public int keyid { get; set; }
                public T propert { get; set; }
            }
  • 相关阅读:
    7.python常用模块
    7.python3实用编程技巧进阶(二)
    7.Flask文件上传
    7.Django CSRF 中间件
    7.Ajax
    6.python内置函数
    6.python3实用编程技巧进阶(一)
    6.jQuery(实例)
    PhpStorm 10.0.1破解激活步骤
    PyCharm 2018.1破解激活步骤
  • 原文地址:https://www.cnblogs.com/wenghan/p/14123863.html
Copyright © 2011-2022 走看看