jquery无刷新分页(附代码下载)

 希望有机会能和大家一起交流学习,220897863程序员之家群欢迎大家加入   

  接上一篇文章,本篇提供下载地址:

https://files.cnblogs.com/suchen1314/JqueryPaging.rar
解压后 App_Code有两个数据库脚本执行一下 并且在PersonBLL类下修改数据库连接
 --通用方法,限制于2005以上数据库
-- =============================================
create  PROCEDURE [dbo].[GetPageByRowNumber]
	@Field nvarchar(1000),
	@TableName  nvarchar(100),
	@condition  nvarchar(1000),--格式为:and (查询条件)  如'and (key=value and key1=value1)'
    @OrderBy nvarchar(1000),
    @pageindx int,
	@PageSize  int,
	@IsCount bit,
    @RecordCount int output     --记录的总数
as 
BEGIN
	--判断是否有排序字段
 
   	if(@OrderBy is null or ltrim(rtrim(@OrderBy))='')
    	begin 
    	       RAISERROR('排序字段不能为空',16,1)
    	       return
    	end 
  set  @OrderBy='order by '+@OrderBy
    
    --组装查询条件,如果没有查询条件,直接跳过
  	if(@condition is not null and ltrim(rtrim(@condition))!='')
 		begin 
             set @condition='where 1=1'+@condition
		end 
	else
		  begin 
				set @condition=''
		  end 
 
	--求记录的总数
  if(@IsCount=1)
	begin 
   		declare @Countsql  nvarchar(max)
		set @Countsql='select @a= count(1) from '+@TableName +' '+@condition
		exec  sp_executesql  @Countsql,N'@a int output',@RecordCount output   
	    
   		print  @RecordCount
		
    end 
   declare @sql  nvarchar(max)

	--分页
	if(@pageindx=1) 
		begin
			set @sql=' select top '+cast(@pagesize as nvarchar )+'  '+ @Field+' from '+@TableName +' '+@condition+' '+@OrderBy
		end 
	else
		begin 
		     declare @startNumber   int 
		     set @startNumber =(@pageindx-1)*@pagesize
			 set @sql='select ROW_NUMBER() over('+@OrderBy+') as number, '+@Field+' from '+@TableName+'  '+@condition  
			 set @sql='SET ROWCOUNT '+Convert(varchar(4),@PageSize)+'; WITH SP_TABLE AS('+@sql   +')  SELECT '+@Field+' from SP_TABLE   where  number>'+CAST(@startNumber as nvarchar)  
		end 
    print @sql
	exec(@sql)
	
 
 
END

  

 
posted @ 2012-03-22 21:27  suchen  阅读(278)  评论(0编辑  收藏  举报