超好用轻量级MVC分页控件JPager.Net(2)

using System; using System.Collections.Generic; using System.Linq; using System.Web; namespace JPager.Net.Web.Models { public class UserParams:JPager.Net.PagerInBase { public int Id { get; set; } public string Name { get; set; } public int ? Age { get; set; } public int Score { get; set; } public string Address { get; set; } public DateTime AddTime { get; set; } } }

UserParams.cs

using System; namespace JPager.Net.Web.Models { public class User { public int Id { get; set; } public string Name { get; set; } public int Age { get; set; } public int Score { get; set; } public string Address { get; set; } public DateTime AddTime { get; set; } } }

view显示

@model JPager.Net.PagerResult<JPager.Net.Web.Models.User> @{ ViewBag.Title = "Index"; } <h2>JPager.Net MVC好用的轻量级分页控件</h2> <div> <div> <form method="get">Name: <input /> Age: <input/> <input type="submit" value="查询" /> </form> </div> <table> <tr> <th>ID</th> <th>Name</th> <th>Age</th> <th>Score</th> <th>Address</th> <th>AddTime</th> </tr> @foreach (JPager.Net.Web.Models.User item in Model.DataList) { <tr> <td>@item.Id</td> <td>@item.Name</td> <td>@item.Age</td> <td>@item.Score</td> <td><a href="https://www.jb51.net/@item.Address" target="_target">@item.Address</a></td> <td>@item.AddTime</td> </tr> } </table> </div> <div> @Html.Raw(Model.PagerHtml()) 共 @Model.Total 条 </div> <script type="text/javascript"> //保持搜索条件 $(function () { $('#Name').val('@ViewBag.SearchName'); $('#Age').val('@ViewBag.SearchAge'); }); </script>

github:https://github.com/decadestory/JPager.Net 

您可能感兴趣的文章:

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:https://www.heiqu.com/wjypfz.html