今天用asp.net配置jqgrid,一天都没有成功,相当的郁闷,请高手指点,我的分不多,希望见谅
用的是示例数据库Northwind
以下为前台代码
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="jqgrid.aspx.cs" Inherits="jQueryPages.jqgrid" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>jqgrid</title>
<link rel="Stylesheet" type="text/css" href="jqGrid/themes/coffee/grid.css" />
<script type="text/javascript" src="jqGrid/jquery.js"></script>
<script type="text/javascript" src="jqGrid/js/grid.base.js"></script>
<script type="text/javascript" src="jqGrid/js/grid.locale-cn.js"></script>
<script type="text/javascript">
$(document).ready(function(){
$("#list").jqGrid({
url:'jqgrid.ashx',
datatype: 'json',
mtype: 'GET',
colNames:['OrderId','CustomerId', 'ShipName'],
colModel :[
{name:'OrderId', index:'OrderId', width:100},
{name:'CustomerId', index:'CustomerId', width:100},
{name:'ShipName', index:'ShipName', width:100, align:'right'}],
pager: $('#pager'),
rowNum:10,
rowList:[10,20,30],
sortname: 'id',
sortorder: "desc",
viewrecords: true,
imgpath: 'jqgrid/themes/basic/images',
caption: 'My first grid'
});
});
</script>
</head>
<body>
<form id="form1" runat="server" enableviewstate="false">
<table id="list" class="scroll"></table>
<div id="pager" class="scroll" style="text-align:center;"></div>
</form>
</body>
</html>
以下为jqgrid.ashx代码
using System;
using System.Collections;
using System.Data;
using System.Data.SqlClient;
using System.Linq;
using System.Web;
using System.Web.Services;
using System.Web.Services.Protocols;
using System.Xml.Linq;
namespace jQueryPages
{
/// <summary>
/// $codebehindclassname$ 的摘要说明
/// </summary>
[WebService(Namespace = "http://tempuri.org/")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
public class jqgrid1 : IHttpHandler
{
public void ProcessRequest(HttpContext context)
{
//不让浏览器缓存
context.Response.Buffer = true;
context.Response.ExpiresAbsolute = DateTime.Now.AddDays(-1);
context.Response.AddHeader("pragma", "no-cache");
context.Response.AddHeader("cache-control", "");
context.Response.CacheControl = "no-cache";
context.Response.ContentType = "text/plain";
DataTable dt = SqlHelper.ExecuteDataSet("select top 20 OrderId,CustomerId,ShipName from Orders order by Orderid asc").Tables[0];
string jsonData = JsonHelper.JsonForJqgrid(dt);
context.Response.Write(jsonData);
}
public bool IsReusable
{
get
{