读书人

起一个jquery绑定及分页源码!100分啊

发布时间: 2012-05-20 16:03:12 作者: rapoo

起一个jquery绑定及分页源码!!!!!!100分啊啊啊啊啊啊啊啊啊啊
如题,要源码

[解决办法]
尼玛,异步啊。
[解决办法]
例子 简单 GridView AJAX 局部刷新分页例子
http://dotnet.aspx.cc/file/GridView-Ajax-Paging.aspx
[解决办法]
更多的代码
采用Jquery无刷新分页插件jquery.pagination.js 实现无刷新分页效果

[解决办法]
很强大
http://demos.telerik.com/aspnet-mvc/grid

可以只把他的js及样式拷贝出来,并按着json样式给数据

[解决办法]
前台html:
<!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>
<title></title>
<script src="js/jquery-1.4.2.js" type="text/javascript"></script>
<script src="js/jquery-1.4.2-vsdoc.js" type="text/javascript"></script>
<script type="text/javascript">
$(function () {
$.post("JQWSXFY.ashx",{"action":"getpagecount"},function (data, status) {
for (var i = 1; i <= data; i++) {
var td = $("<td><a href=''>" + i + "</a></td>");
$("#trPage").append(td);
}
$("#trPage td").click(function (e) {
e.preventDefault();
$.post("JQWSXFY.ashx", { "action": "getpagedata", "pagenum":$(this).text() },
function (data, staus) {
var comments = $.parseJSON(data);
$("#ulComment").empty();
for (var i = 0; i < comments.length; i++) {
var comment = comments[i];
var li = "<li>" + comment.id + comment.name + comment.Development + comment.Note + comment.Datetime + "</li>";
$("#ulComment").append(li);
}
});
});

});
});

</script>
</head>
<body>
<div >
<ul id="ulComment">


</ul>
<table>
<tr id="trPage"></tr>

</table>
</div>
</body>
</html>

后台一般处理程序:
<%@ WebHandler Language="C#" Class="JQWSXFY" %>

using System;
using System.Web;
using System.Data;
using System.Data.Sql;
using System.Data.SqlClient;
using System.Configuration;
using System.Web.Script.Serialization;
using System.Collections.Generic;

public class JQWSXFY : IHttpHandler {

public void ProcessRequest (HttpContext context) {
context.Response.ContentType = "text/plain";
string action=context.Request["action"];//无法获取action的值
//string action=context.Request.Form["action"];
// string action=context.Request.QueryString["action"];
// string action = context.Request.Params["a"];
// string action = "getpagedata";
string pagenum = context.Request["pagenum"];//无法获取pagenum的值
//string pagenum = "1";

int pagecount;//总页数
if (action == "getpagecount")


{
string cmdString = @"select count(*) from Table1";
using (SqlConnection conn = new SqlConnection(ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString))
{
using (SqlCommand cmd = new SqlCommand(cmdString, conn))
{
conn.Open();
int count = Convert.ToInt32(cmd.ExecuteScalar());
pagecount = count / 10;
}

}
if (pagecount % 10 != 0)
{
pagecount++;
}
context.Response.Write(pagecount);
}
else if (action == "getpagedata")
{
string cmdString = @"select * from (select id ,name,Development,Note,Datetime,Row_Number()over(order by id) as rownum from table1)t where t.rownum>=@pagenum*10-9 and t.rownum<=@pagenum*10";
using (SqlConnection conn = new SqlConnection(ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString))
{
using (SqlCommand cmd = new SqlCommand(cmdString, conn))
{
conn.Open();
cmd.Parameters.Add("@pagenum", pagenum);
SqlDataAdapter da = new SqlDataAdapter(cmd);
DataSet ds = new DataSet();
da.Fill(ds);


List<comment> list = new List<comment>();
foreach (DataRow myRow in ds.Tables[0].Rows)
{

list.Add(new comment() { id = myRow["id"].ToString(), name = myRow["name"].ToString(), Development = myRow["Development"].ToString(), Note = myRow["Note"].ToString(), Datetime = myRow["Datetime"].ToString() });
}
JavaScriptSerializer jss = new JavaScriptSerializer();
context.Response.Write(jss.Serialize(list));


}

}
}


}


public bool IsReusable
{
get
{
return false;
}
}

public class comment
{
public string id { get; set; }
public string name { get; set; }
public string Development { get; set; }
public string Note { get; set; }
public string Datetime { get; set; }

}

}

读书人网 >asp.net

热点推荐