jquery - 如何在没有 PagedList 的 Asp.Net MVC 中分页?
问题描述
我想使用 Asp.Net MVC 进行分页。我的表正在加载 jquery。我试过 PagedList 但它总是在其他页面上显示相同的结果。我该怎么做?我今天需要尽快完成,请帮忙。
public ActionResult Index()
{
var sessionId = Convert.ToInt32(Session["UserID"]);
ViewBag.Name = Session["FirstName"];
ViewBag.Company = Session["Company"];
ViewBag.Logo = Session["Logo"];
List<DetailModel> messages = new List<DetailModel>();
DetailRepository r = new DetailRepository();
messages = r.DetailList(sessionId);
return View(messages.ToList());
}
public JsonResult DetailList(string basTarih, string bitTarih)
{
var sessionId = Convert.ToInt32(Session["UserID"]);
List<DetailModel> messages = new List<DetailModel>();
DetailRepository r = new DetailRepository();
DateTime start = DateTime.MinValue;
DateTime end = DateTime.MaxValue;
var sDs = basTarih;
var eDs = bitTarih;
DateTime.TryParse(sDs, out start);
DateTime.TryParse(eDs, out end);
messages = r.DetailList(sessionId);
if (start != DateTime.MinValue && end != DateTime.MinValue)
{
messages = messages.Where(x => Convert.ToDateTime(x.CreatedDate) >= start && Convert.ToDateTime(x.CreatedDate) <= end).ToList();
}
return Json(messages, JsonRequestBehavior.AllowGet);
}
<table class="table" id="detailTable">
<thead>
<tr>
<td>
<span id="clpse-icon" style="color:#5D78FF; padding-left:25px;" onclick="sortTable(0)">
Parça Sayısı
<i class="flaticon2-arrow-down rotate" style="font-size:0.6rem;"></i>
</span>
</td>
<td>
<span id="clpse-icon2" onclick="sortTable(1)" style="padding-left:1px;">Eklenme Tarihi <i class="flaticon2-arrow-down rotate" style="font-size:0.6rem;"></i></span>
</td>
<td></td>
</tr>
</thead>
<tbody id="detailliste"></tbody>
</table>
解决方案
您可以使用查询字符串来处理分页?page=
在您的 c# 代码中,您可以使用skip
andtake
来获取页面中的项目。
您可以参考此链接以获取更多详细信息https://stackoverflow.com/a/41327646/4964569
推荐阅读
- firebase - 文档或集合的人类可读键
- javascript - react 钩子中的 useEffect 执行顺序及其内部清理逻辑是什么?
- python - Pandas 中的聚合
- asp.net - ASP.NET Gridview 选定索引更改未触发
- flutter - 添加flutter firebase auth ui后应用程序崩溃
- java - 为什么我的 Java 使用者不能读取我创建的数据?
- c++ - QNX 6.5.0 抓取屏幕或窗口 Qt C++
- firebase - Firebase - 如何从 onCreate 云函数监听器发送电子邮件验证?
- javascript - 如果关闭或在后台运行,我应该如何在反应原生 Firebase 应用程序中处理推送通知
- javascript - 简单的密码登录不起作用。Javascript