http://www.c-sharpcorner.com/UploadFile/0c1bb2/sorting-paging-searching-in-Asp-Net-mvc-5/

https://dzone.com/articles/table-sorting-pagination

https://datatables.net/

Index.cshtm:

@{
ViewBag.Title = "Paging Sorting Searching In ASP.NET MVC 5";
}
<script src="~/Scripts/jquery-1.10.2.min.js"></script>
<link rel="stylesheet" type="text/css" href="~/css/jquery.dataTables.min.css">
<script type="text/javascript" language="javascript" src="~/Scripts/jquery.dataTables.min.zh.js" charset="utf-8"></script>
<script> $(document).ready(function () {
//Call EmpDetails jsonResult Method http://cdn.datatables.net/1.10.10/css/jquery.dataTables.min.css
$.getJSON("Home/EmpDetails",
function (json) {
var tr; //Append each row to html table
for (var i = 0; i < json.length; i++) {
tr = $('<tr/>');
tr.append("<td>" + json[i].Id + "</td>");
tr.append("<td>" + json[i].Name + "</td>");
tr.append("<td>" + json[i].City + "</td>");
tr.append("<td>" + json[i].Address + "</td>");
$('table').append(tr); }
$('#EmpInfo').DataTable();
}); }); </script>
<hr />
<div class="form-horizontal">
<table id="EmpInfo" class="table table-bordered table-hover">
<thead>
<tr>
<th>Id</th>
<th>Name</th>
<th>City</th>
<th>Address</th>
</tr>
</thead>
<tbody></tbody>
</table> </div>

  _Layout.cshtml:

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>@ViewBag.Title - www.dusystem.com 捷为工作室</title>
<link href="~/Content/Site.css" rel="stylesheet" type="text/css" />
<link href="~/Content/bootstrap.min.css" rel="stylesheet" type="text/css" />
<script src="~/Scripts/modernizr-2.6.2.js"></script> </head>
<body>
<div class="navbar navbar-inverse navbar-fixed-top">
<div class="container">
<div class="navbar-header">
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-collapse">
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
@Html.ActionLink("www.dusystem.com 捷为工作室", "Index", "Home", new { area = "" }, new { @class = "navbar-brand" })
</div>
<div class="navbar-collapse collapse">
<ul class="nav navbar-nav">
</ul>
</div>
</div>
</div> <div class="container body-content">
@RenderBody()
<hr />
<footer>
<p>© @DateTime.Now.Year - www.dusystem.com 捷为工作室</p>
</footer>
</div> <script src="~/Scripts/bootstrap.min.js"></script>
</body>
</html>

  HomeController.cs:

using PagingSoringInMVC.Models;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc; namespace PagingSoringInMVC.Controllers
{ /// <summary>
///
/// </summary>
public class HomeController : Controller
{
// GET: Home
[HttpGet]
public ActionResult Index()
{
return View();
} [HttpGet]
public JsonResult EmpDetails()
{
//Creating List
List<Employee> ObjEmp = new List<Employee>()
{
//Adding records to list
new Employee
{
Id = 1, Name = "Vithal Wadje", City = "Latur", Address = "Kabansangvi"
},
new Employee
{
Id = 2, Name = "Sudhir Wadje", City = "Mumbai", Address = "Kurla"
},
new Employee
{
Id = 3, Name = "Dinesh Beniwal", City = "New Delhi", Address = "Noida"
},
new Employee
{
Id = 4, Name = "Dhananjay Kumar", City = "New Delhi", Address = "Delhi"
},
new Employee
{
Id = 5, Name = "Jitendra Gund", City = "Pune", Address = "Pune"
},
new Employee
{
Id = 6, Name = "Anil Kumar", City = "chandigarh", Address = "chandigarh"
},
new Employee
{
Id = 7, Name = "Ramesh", City = "Mumbai", Address = "Kurla"
},
new Employee
{
Id = 8, Name = "涂一", City = "北京市", Address = "东城区学城路"
},
new Employee
{
Id = 9, Name = "江六", City = "北京市", Address = "西城区西长安街"
},
new Employee
{
Id = 10, Name = "黄七", City = "北京市", Address = "昌平区大学城路"
},
new Employee
{
Id = 11, Name = "孙八", City = "上海市", Address = "徐家汇区延安西路"
},
new Employee
{
Id = 12, Name = "Sudhir Wadje", City = "Mumbai", Address = "Kurla"
},
new Employee
{
Id = 13, Name = "Dinesh Beniwal", City = "New Delhi", Address = "Noida"
},
new Employee
{
Id = 14, Name = "Dhananjay Kumar", City = "New Delhi", Address = "Delhi"
},
new Employee
{
Id = 15, Name = "Jitendra Gund", City = "Pune", Address = "Pune"
},
new Employee
{
Id = 16, Name = "Anil Kumar", City = "chandigarh", Address = "chandigarh"
},
new Employee
{
Id = 17, Name = "Ramesh", City = "Mumbai", Address = "Kurla"
},
new Employee
{
Id = 18, Name = "赵二", City = "深圳市", Address = "罗湖区沿河北路"
},
new Employee
{
Id = 19, Name = "张三", City = "深圳市", Address = "南山区科苑南路"
},
new Employee
{
Id = 20, Name = "李四", City = "深圳市", Address = "南山区后海大道"
},
new Employee
{
Id = 21, Name = "Vithal Wadje", City = "Latur", Address = "Kabansangvi"
},
new Employee
{
Id = 22, Name = "Sudhir Wadje", City = "Mumbai", Address = "Kurla"
},
new Employee
{
Id = 23, Name = "Dinesh Beniwal", City = "New Delhi", Address = "Noida"
},
new Employee
{
Id = 24, Name = "Dhananjay Kumar", City = "New Delhi", Address = "Delhi"
},
new Employee
{
Id = 25, Name = "Jitendra Gund", City = "Pune", Address = "Pune"
},
new Employee
{
Id = 26, Name = "Anil Kumar", City = "chandigarh", Address = "chandigarh"
},
new Employee
{
Id = 27, Name = "Ramesh", City = "Mumbai", Address = "Kurla"
},
new Employee
{
Id = 28, Name = "刘杰", City = "深圳市", Address = "福田区福中路"
},
new Employee
{
Id = 29, Name = "徐达", City = "深圳市", Address = "罗湖区爱国路"
},
new Employee
{
Id = 30, Name = "王五", City = "深圳市", Address = "罗湖区人民路"
}, };
//return Json
return Json(ObjEmp, JsonRequestBehavior.AllowGet);
}
}
}

  Employee.cs:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks; namespace PagingSoringInMVC.Models
{
public class Employee
{
public int Id { get; set; }
public string Name { get; set; }
public string City { get; set; }
public string Address { get; set; }
}
}

  

Csharp:Paging Sorting Searching In ASP.NET MVC 5的更多相关文章

  1. [转]Paging, Searching and Sorting in ASP.Net MVC 5

    本文转自:http://www.c-sharpcorner.com/UploadFile/4b0136/perform-paging-searching-sorting-in-Asp-Net-mvc- ...

  2. [转]Sorting, Filtering, and Paging with the Entity Framework in an ASP.NET MVC Application (3 of 10)

    本文转自:http://www.asp.net/mvc/overview/older-versions/getting-started-with-ef-5-using-mvc-4/sorting-fi ...

  3. ASP.NET MVC WebGrid – Performing true AJAX pagination and sorting 【转】

    ASP.NET MVC WebGrid – Performing true AJAX pagination and sorting FEBRUARY 27, 2012 14 COMMENTS WebG ...

  4. ASP.NET MVC with Entity Framework and CSS一书翻译系列文章之目录导航

    ASP.NET MVC with Entity Framework and CSS是2016年出版的一本比较新的.关于ASP.NET MVC.EF以及CSS技术的图书,我将尝试着翻译本书以供日后查阅. ...

  5. 【jqGrid for ASP.NET MVC Documentation】.学习笔记.2.jqGrid Model-View-Controller 分离

    1 基本 分离代码 和 描述 ,在ASP.NET MVC 应用程序中是非常重要的.因此,jqGrid 的 mvc 模式使用一个共同的网格安装设置,包括 Model ,Controller 和 View ...

  6. ASP.NET MVC 5 實作 GridView 分頁

    本文用 ASP.NET MVC 5 實作一個 GridView,功能包括: 分頁(paging).關鍵字過濾(filtering).排序(sorting).AJAX 非同步執行,外觀上亦支援 Resp ...

  7. ASP.NET MVC搭建项目后台UI框架—5、Demo演示Controller和View的交互

    目录 ASP.NET MVC搭建项目后台UI框架—1.后台主框架 ASP.NET MVC搭建项目后台UI框架—2.菜单特效 ASP.NET MVC搭建项目后台UI框架—3.面板折叠和展开 ASP.NE ...

  8. ASP.NET MVC搭建项目后台UI框架—6、客户管理(添加、修改、查询、分页)

    目录 ASP.NET MVC搭建项目后台UI框架—1.后台主框架 ASP.NET MVC搭建项目后台UI框架—2.菜单特效 ASP.NET MVC搭建项目后台UI框架—3.面板折叠和展开 ASP.NE ...

  9. ASP.NET MVC搭建项目后台UI框架—7、统计报表

    ASP.NET MVC搭建项目后台UI框架—1.后台主框架 ASP.NET MVC搭建项目后台UI框架—2.菜单特效 ASP.NET MVC搭建项目后台UI框架—3.面板折叠和展开 ASP.NET M ...

随机推荐

  1. WPF常用样式总结

    常用控件样式: <ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation ...

  2. ZKWeb网页框架1.7正式发布

    1.7.0更新的内容有 更新项目格式到新的csproj 更新项目模板 打开新创建的Asp.Net Core项目将需要VS 2017,Asp.Net和Owin项目仍可以用VS 2015 补上插件模板的P ...

  3. Codeforces gym101612 E.Equal Numbers(贪心)

    传送:http://codeforces.com/gym/101612 题意:给出一个大小为n的序列a[i],每次选其中一个数乘以一个正整数,问进行k步操作后最少剩下多少种数字,输出0≤k≤n,所有的 ...

  4. Struts2再爆远程命令执行漏洞![W3bSafe]Struts2-048 Poc Shell及防御修复方案抢先看!

    漏洞概述 Apache Struts是美国阿帕奇(Apache)软件基金会负责维护的一个开源项目,是一套用于创建企业级Java Web应用的开源MVC框架.在Struts 2.3.x 系列的 Show ...

  5. WebRTC 学习之 Conference 实现混音混屏

    混音 混音的意义就是将多个音频流混成一路音频,在Conference 的实现中有分为终端实现和服务器实现. 1. 终端混音实现: 终端接受到多路(一般是多个用户)的音频流之后,在终端本地将多路音频流混 ...

  6. 为什么 echo 3 . print(2) . print(4) . 5 . 'c'的结果是45c2131

    例子:请写出echo 3 . print(2) . print(4) . 5 . 'c'的输出结果为____? 许多人看到这个题的第一印象是输出结果不就是3245c嘛,然而正确的是答案却是45c213 ...

  7. OpenStack-Ocata版+CentOS7.6 云平台环境搭建 — 5.在控制节点上部署计算服务Nova

    计算服务Nova使用OpenStack Compute来托管和管理云计算系统. OpenStack Compute是基础架构即服务(IaaS)系统的主要部分. 主要模块用Python实现.OpenSt ...

  8. 机器学习技法笔记:07 Blending and Bagging

    Roadmap Motivation of Aggregation Uniform Blending Linear and Any Blending Bagging (Bootstrap Aggreg ...

  9. Servlet-获取页面的元素的值的方式以及区别

    request.getParameter() 返回客户端的请求参数的值:request.getParameterNames() 返回所有可用属性名的枚举: request.getParameterVa ...

  10. 【LeetCode】9. 回文数

    题目 判断一个整数是否是回文数.回文数是指正序(从左向右)和倒序(从右向左)读都是一样的整数. 示例 1:输入: 121 输出: true 示例 2:输入: -121 输出: false 解释: 从左 ...