首页 > 代码库 > ASP.NET MVC获取微信返回的json数据分页
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); }
ASP.NET MVC获取微信返回的json数据分页
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。