zoukankan      html  css  js  c++  java
  • ASP.NET MVC获取微信返回的json数据分页

    View

    @model JiaYe.WeiXin.Models.ViewModels.UserViewModel
    <div class="pull-left pagination">
        <ul class="pagination pagination-outline">
        @{
           //分页算法:(总记录数+每页记录数-1)/每页记录数 var totalPageNum = (Model.OpenIdResult.openid.Count + 10 - 1)/10; for (int id = 1; id
    <= totalPageNum; id++) { <li class="page-number"> <a href="/User/Index/@id">@id</a> </li> } } </ul> </div>

    Controller

    public ActionResult Index(int id = 1)
            {
                var userresult = UserApi.Get(GetAccessToken(), "");
                int pagesize = id*10;
                List<BatchGetUserInfoData> userList = new List<BatchGetUserInfoData>();
           //每十个数据为一页
    for (int i = pagesize - 10;i < ((pagesize - userresult.data.openid.Count < 0) ? pagesize : userresult.data.openid.Count);i++) { BatchGetUserInfoData user = new BatchGetUserInfoData(); user.openid = userresult.data.openid[i]; userList.Add(user); } UserViewModel userViewModel = new UserViewModel(); userViewModel.OpenIdResult = userresult.data; userViewModel.BatchGetUserInfoResult = UserApi.BatchGetUserInfo(GetAccessToken(), userList); return View(userViewModel); }
  • 相关阅读:
    2020暑假牛客多校9 B
    2020暑假牛客多校10 C -Decrement on the Tree (边权转点权处理)
    HDU 5876 补图的最短路
    CSP初赛复习
    遗传算法
    排列组合
    和式 sigma的使用
    多项式的各种操作
    三分
    NOIP2018普及游记
  • 原文地址:https://www.cnblogs.com/xiaomen/p/6252372.html
Copyright © 2011-2022 走看看