https://www.codeproject.com/Articles/1118363/GridView-with-Server-Side-Filtering-Sorting-and-Pa

http://mvcgrid.net/download

https://github.com/joeharrison714/MVCGrid.Net

https://www.nuget.org/packages/PagedList.Mvc/

https://datatables.net/download/index

https://archive.codeplex.com/?p=jqmvcgrid

https://www.nuget.org/packages/jQuery.Grid/

https://github.com/atatanasov/gijgo

https://github.com/TroyGoode/PagedList

http://gijgo.com/grid

jadgrid.aspx

<!DOCTYPE html>
<!--HTML5 doctype-->
<html>
<head runat="server">
<meta charset="utf-8">
<meta name="viewport" content="width=device-width,initial-scale=1,user-scalable=0">
<title>JQGrid 测试分页用</title>
<link href="~/Styles/Site.css" rel="stylesheet" type="text/css" />
<script src="JQGridReq/jquery-1.9.0.min.js" type="text/javascript"></script>
<link href="JQGridReq/jquery-ui-1.9.2.custom.css" rel="stylesheet" type="text/css" />
<script src="JQGridReq/jquery.jqGrid.js" type="text/javascript"></script>
<link href="JQGridReq/ui.jqgrid.css" rel="stylesheet" type="text/css" />
<script src="JQGridReq/grid.locale-cn.js" type="text/javascript"></script>
<script type="text/javascript">
$(function () {
$("#UsersGrid").jqGrid({
url: 'geovinHandler.ashx',
datatype: 'json',
height: 550,
colNames: ['序號', '會員卡號', '會員姓名', '保證單號', '會員登錄賬號', '發佈時間'],
colModel: [
{ name: 'LotteryId', index: 'LotteryId', width: 100, sortable: true },
{ name: 'LotteryVipNo', width: 100, sortable: true, editable: true },
{ name: 'LotteryVipName', width: 100, sortable: true, editable: true },
{ name: 'LotteryGuaranteeNumber', width: 100, sortable: true, editable: true },
{ name: 'LotteryBranchAccount', width: 100, sortable: true, editable: true },
{ name: 'LotteryAddTime',formatter: "date",ormatoptions: { srcformat: "ISO8601Long", newformat: "m/d/Y h:i A" }, width: 150, sortable: true }
],
rowNum: 50,
mtype: 'GET',
loadonce: true,
rowList: [50, 100, 300],
pager: '#UsersGridPager',
sortname: 'LotteryId',
viewrecords: true,
sortorder: 'asc',
editurl: 'geovinHandler.ashx',
caption: '會員穫得中獎名單'
}); $("#UsersGrid").jqGrid('navGrid', '#UsersGridPager',
{
edit: true,
add: true,
del: true,
search: true,
searchtext: "Search",
addtext: "Add",
edittext: "Edit",
deltext: "Delete"
},
{ //EDIT
// height: 300,
// width: 400,
// top: 50,
// left: 100,
// dataheight: 280,
closeOnEscape: true, //Closes the popup on pressing escape key
reloadAfterSubmit: true,
drag: true,
afterSubmit: function (response, postdata) {
if (response.responseText == "") { $(this).jqGrid('setGridParam', { datatype: 'json' }).trigger('reloadGrid'); //Reloads the grid after edit
return [true, '']
}
else {
$(this).jqGrid('setGridParam', { datatype: 'json' }).trigger('reloadGrid'); //Reloads the grid after edit
return [false, response.responseText]//Captures and displays the response text on th Edit window
}
},
editData: {
EmpId: function () {
var sel_id = $('#UsersGrid').jqGrid('getGridParam', 'selrow');
var value = $('#UsersGrid').jqGrid('getCell', sel_id, 'LotteryId');
return value;
}
}
},
{
closeAfterAdd: true, //Closes the add window after add 如何自定義添加窗口?
afterSubmit: function (response, postdata) {
if (response.responseText == "") { $(this).jqGrid('setGridParam', { datatype: 'json' }).trigger('reloadGrid')//Reloads the grid after Add
return [true, '']
}
else {
$(this).jqGrid('setGridParam', { datatype: 'json' }).trigger('reloadGrid')//Reloads the grid after Add
return [false, response.responseText]
}
}
},
{ //DELETE
closeOnEscape: true,
closeAfterDelete: true,
reloadAfterSubmit: true,
closeOnEscape: true,
drag: true,
afterSubmit: function (response, postdata) {
if (response.responseText == "") { $("#UsersGrid").trigger("reloadGrid", [{ current: true}]);
return [false, response.responseText]
}
else {
$(this).jqGrid('setGridParam', { datatype: 'json' }).trigger('reloadGrid');
return [true, response.responseText]
}
},
delData: {
EmpId: function () {
var sel_id = $('#UsersGrid').jqGrid('getGridParam', 'selrow');
var value = $('#UsersGrid').jqGrid('getCell', sel_id, 'LotteryId');
return value;
}
}
},
{//SEARCH
closeOnEscape: true });
}); </script>
</head>
<body>
<form id="form1" runat="server">
<div>
<table id="UsersGrid" cellpadding="0" cellspacing="0">
</table>
<div id="UsersGridPager">
</div>
</div>
</form>
</body>
</html>

  geovinHandler.ashx:

 /// <summary>
/// $codebehindclassname$ 的摘要说明
/// geovindu
/// 20180128
/// 涂聚文
/// </summary>
[WebService(Namespace = "http://tempuri.org/")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
public class geovinHandler : IHttpHandler
{ DuMembershipLotteryBLL bll = new DuMembershipLotteryBLL();
/// <summary>
///
/// </summary>
/// <param name="context"></param>
public void ProcessRequest(HttpContext context)
{
HttpRequest request = context.Request;
HttpResponse response = context.Response; System.Collections.Specialized.NameValueCollection forms = context.Request.Form;
string strOperation = forms.Get("oper"); //
response.Write(strOperation);
string strResponse = string.Empty;
string _search = request["_search"];
string numberOfRows = request["rows"];
string pageIndex = request["page"];
string sortColumnName = request["sidx"];
string sortOrderBy = request["sord"];
int totalRecords;
List<DuMembershipLotteryInfo> info = new List<DuMembershipLotteryInfo>();
if (strOperation == null)
{
info = bll.SelectDuMembershipLotteryPaging(Convert.ToInt32(numberOfRows), Convert.ToInt32(pageIndex), sortColumnName, sortOrderBy, out totalRecords);
string output = BuildJQGridResults(info, Convert.ToInt32(numberOfRows), Convert.ToInt32(pageIndex), Convert.ToInt32(totalRecords));
response.Write(output);
}
else if (strOperation == "del")
{
string strEmpId = forms.Get("id").ToString();
//DeleteEmployee(strEmpId);
bool del = false;
del = bll.DeleteDuMembershipLottery(Convert.ToInt32(strEmpId));
if (del)
{
strResponse = "删除成功";
}
context.Response.Write(strResponse); }
else
{
string strOut = string.Empty;
AddEdit(forms, info, out strOut);
context.Response.Write(strOut);
}
} /// <summary>
///
/// </summary>
/// <param name="users"></param>
/// <param name="numberOfRows"></param>
/// <param name="pageIndex"></param>
/// <param name="totalRecords"></param>
/// <returns></returns>
private string BuildJQGridResults(List<DuMembershipLotteryInfo> infos, int numberOfRows, int pageIndex, int totalRecords)
{ JQGridResults result = new JQGridResults();
List<JQGridRow> rows = new List<JQGridRow>();
foreach (DuMembershipLotteryInfo info in infos)
{
JQGridRow row = new JQGridRow();
row.id = info.LotteryId;
row.cell = new string[6];
row.cell[0] = info.LotteryId.ToString();
row.cell[1] = info.LotteryVipNo;
row.cell[2] = info.LotteryVipName;
row.cell[3] = info.LotteryGuaranteeNumber;
row.cell[4] = info.LotteryBranchAccount;
row.cell[5] = info.LotteryAddTime.ToString();
rows.Add(row);
}
result.rows = rows.ToArray();
result.page = pageIndex;
result.total = totalRecords / numberOfRows;
result.records = totalRecords;
return new JavaScriptSerializer().Serialize(result);
} /// <summary>
/// 添加或修改操作
/// </summary>
/// <param name="forms"></param>
/// <param name="collectionEmployee"></param>
/// <param name="strResponse"></param>
private void AddEdit(NameValueCollection forms, List<DuMembershipLotteryInfo> collectionInfo, out string strResponse)
{
string strOperation = forms.Get("oper");
string strEmpId = string.Empty;
DuMembershipLotteryInfo info = new DuMembershipLotteryInfo();
info.LotteryVipNo = forms.Get("LotteryVipNo").ToString();
info.LotteryVipName = forms.Get("LotteryVipName").ToString();
info.LotteryGuaranteeNumber = forms.Get("LotteryGuaranteeNumber").ToString();
info.LotteryBranchAccount = forms.Get("LotteryBranchAccount").ToString();
info.LotteryAddTime = DateTime.Now;
int saveok = 0;
//string strdate = forms.Get("UpdateTime").ToString(); if (strOperation == "add")
{
string result = "0";
strEmpId = (Convert.ToInt32(result) + 1).ToString();
saveok = bll.InsertDuMembershipLottery(info);
if (saveok > 0)
{
strResponse = "record successfully added添加成功";
}
else
{ strResponse = ""; }
}
else if (strOperation == "edit")
{
strEmpId = forms.Get("EmpId").ToString(); //获取修改ID
info.LotteryId = Convert.ToInt32(strEmpId);
saveok=bll.UpdateDuMembershipLottery(info);
if (saveok > 0)
{
strResponse = "record successfully updated修改成功";
}
else
{ strResponse = ""; }
}
else
{
strResponse = "";
} }
/// <summary>
///
/// </summary>
public bool IsReusable
{
get
{
return false;
}
}
}

  

JqGrid: paging int asp.net的更多相关文章

  1. 使用jqgrid的C#/asp.net mvc开发者的福音 jqgrid-asp.net-mvc

    你是否使用jqgrid? 你是否想在C#/asp.net mvc中使用jqgrid? 那你很可能曾经为了分析jqgrid的request url用fiddler忙活了2个小时.(如果你要使用jqgri ...

  2. JqGrid: Add,Edit,Del in asp.net

    https://github.com/1rosehip/jplist https://github.com/free-jqgrid/jqGrid https://plugins.jquery.com/ ...

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

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

  4. 能省则省:在ASP.NET Web API中通过HTTP Headers返回数据

    对于一些返回数据非常简单的 Web API,比如我们今天遇到的“返回指定用户的未读站内短消息数”,返回数据就是一个数字,如果通过 http response body 返回数据,显得有些奢侈.何不直接 ...

  5. [转]Efficiently Paging Through Large Amounts of Data

    本文转自:http://msdn.microsoft.com/en-us/library/bb445504.aspx Scott Mitchell April 2007 Summary: This i ...

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

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

  7. java、asp.net 通用分页码函数

    <script type="text/javascript"> $(document).ready(function(){ ajaxGetPaging(1); }); ...

  8. asp.net sql无限极分类实例程序

    数据库结构  代码如下 复制代码 create table category(    id                  int,                    clsno         ...

  9. ASP.NET MVC 表格操作

    Beginners Guide for Creating GridView in ASP.NET MVC 5 http://www.codeproject.com/Articles/1114208/B ...

随机推荐

  1. AFNetworking 3.0中调用[AFHTTPSessionManager manager]方法导致内存泄漏的解决办法

    在使用AFNetworking3.0框架,使用Instruments检查Leaks时,检测到1000多个内存泄漏的地方,定位到 [AFHTTPSessionManager manager] 语句中,几 ...

  2. Java设计模式----中介者模式

    说到中介大家都不会陌生,买房子租房子有中介,出国留学有中介,买卖二手车还是有中介.那么中介到底是个什么角色呢?实际上,中介就是让买卖双方不必面对面直接交流,由他/她来完成买卖双方的交易,达到解耦买卖人 ...

  3. 顺藤摸瓜:一个专黑建筑行业的QQ黏虫团伙现形记

    QQ粘虫是已经流行多年的盗号木马,它会伪装QQ登陆界面,诱骗受害者在钓鱼窗口提交账号密码.近期,360QVM引擎团队发现一支专门攻击建筑行业人群的QQ粘虫变种,它伪装为招标文档,专门在一些建筑/房产行 ...

  4. libRTMP 整体说明

    函数结构 (libRTMP)的整体的函数调用结构图如下图所示: 原图地址:http://img.my.csdn.net/uploads/201602/10/1455087168_7199.png 基本 ...

  5. Android开发工程师文集-1 小时学会SQLite

    前言 大家好,给大家带来Android开发工程师文集-1 小时学会SQLite的概述,希望你们喜欢 内容 什么是Sqlite: 效率高,开源,小型,程序驱动,支持事务操作,无数据类型,可嵌入的关系型数 ...

  6. Java-大数据方向学习和已掌握知识点整理

    现在的项目是大数据相关项目,一路走来从最初的 C 开发到 Java 再到 大数据,不容易 大数据方向知识点太多,优先掌握了主流的一些技术并运用到了现在的项目中 另外也整理了一份java开发和项目管理方 ...

  7. 排名前 16 的 Java 工具类

    在Java中,工具类定义了一组公共方法,这篇文章将介绍Java中使用最频繁及最通用的Java工具类.以下工具类.方法按使用流行度排名,参考数据来源于Github上随机选取的5万个开源项目源码. 一. ...

  8. Spring 源码分析之 bean 实例化原理

    本次主要想写spring bean的实例化相关的内容.创建spring bean 实例是spring bean 生命周期的第一阶段.bean 的生命周期主要有如下几个步骤: 创建bean的实例 给实例 ...

  9. Pthon常用模块之requests,urllib和re

    urllib Python标准库中提供了:urllib等模块以供Http请求,但是,它的 API 太渣了. 它需要巨量的工作,甚至包括各种方法覆盖,来完成最简单的任务, 下面是简单的使用urllib来 ...

  10. 把本地项目放进新建的仓库(idea)

    1,获取仓库地址 比如: git@bitbucket.org:360717118/springboot_servlet-filter-listener-file.git,   2,idea 设置: