主頁(yè) > 知識(shí)庫(kù) > asp.net利用存儲(chǔ)過(guò)程和div+css實(shí)現(xiàn)分頁(yè)(類似于博客園首頁(yè)分頁(yè))

asp.net利用存儲(chǔ)過(guò)程和div+css實(shí)現(xiàn)分頁(yè)(類似于博客園首頁(yè)分頁(yè))

熱門標(biāo)簽:地圖標(biāo)注多個(gè)行程 銅川小型外呼系統(tǒng)運(yùn)營(yíng)商 浙江外呼系統(tǒng)怎么安裝 上海楊浦怎么申請(qǐng)申請(qǐng)400電話 廈門商鋪地圖標(biāo)注 云南外呼電銷機(jī)器人系統(tǒng) 海外地圖標(biāo)注門市標(biāo) 山西防封卡電銷卡套餐 陜西人工外呼系統(tǒng)哪家好
首先聲明以下幾點(diǎn):
1、也許講解有點(diǎn)初級(jí),希望高手不要“噴”我,因?yàn)槲抑啦⒉皇敲恳粋€(gè)人都是高手,我也怕高手們說(shuō)我裝13,小生不才;
2、如有什么不對(duì)的地方,還希望大家指出,一定虛心學(xué)習(xí);
3、本文屬于作者原創(chuàng),尊重他人勞動(dòng)成果,轉(zhuǎn)載請(qǐng)注明作者,謝謝。
下面開(kāi)講:
  首先說(shuō)下思路,寫(xiě)一個(gè)存儲(chǔ)過(guò)程,我也找了一個(gè)存儲(chǔ)過(guò)程,不過(guò)不是我寫(xiě)的,出處:http://www.cnblogs.com/zhongweiv/archive/2011/10/31/JqueryPagination.html 這是一個(gè)通過(guò)jqurey+ajax實(shí)現(xiàn)無(wú)刷新分頁(yè)的例子,應(yīng)該也不錯(cuò),因?yàn)橛械臅r(shí)候要無(wú)刷新嘛,我用的存儲(chǔ)過(guò)程就是從那里copy來(lái)的,但是我看了58.com還有一些其他的一些網(wǎng)站信息分頁(yè)都不會(huì)通過(guò)無(wú)刷新的,所以我特地的寫(xiě)了一個(gè)有刷新的分頁(yè)的方法,好了,先寫(xiě)一個(gè)存儲(chǔ)過(guò)程,然后就是通過(guò)div+css來(lái)布局點(diǎn)頁(yè)碼傳到該頁(yè)面的參數(shù)的值了,思路是通過(guò)用StringBuilder類后臺(tái)布局div以實(shí)現(xiàn)動(dòng)態(tài)的頁(yè)碼,然后通過(guò)頁(yè)碼調(diào)用存儲(chǔ)過(guò)程,得到相應(yīng)的信息,最后就是一些細(xì)節(jié)了,不斷的運(yùn)行調(diào)試找出BUG并改正...
一、首先看下頁(yè)面前臺(tái)代碼
復(fù)制代碼 代碼如下:

%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Page.aspx.cs" Inherits="Jquery.Page"%>
!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>Tandy Tang有刷新分頁(yè).../title>
style type="text/css">
/*分頁(yè)部分 start*/
ul
{
margin:0px;
padding:0px;
}
.page
{
width:700px;
background-color:#ffffff;
height:50px;
margin-top:15px;
}
.page ul li
{
float:left;
display:block;
width:28px;
height:23px;
text-align:center;
margin-left:1px;
vertical-align:middle;
border-style:solid;
border-width:1px;
border-color:#b1add0;
}
.page ul li span
{
display:block;
width:28px;
height:23px;
background-color:#2d8da3;
}
.page ul li span a
{
color:#ffffff;
}
.page ul li a
{
display:block;
width:28px;
height:19px;
text-decoration:none;
color:#354c7e;
font-size:12px;
vertical-align:middle;
padding-top:4px;
}
.page ul li a:hover
{
background-color:#2d8da3;
display:block;
width:28px;
height:19px;
}
.page .point
{
background-color:#ffffff;
width:20px;
height:24px;
display:block;
border-style:solid;
border-width:0px;
border-color:#ffffff;
}
.page .pre
{
width:48px;
height:22px;
display:block;
text-align:center;
border-style:solid;
border-width:1px;
border-color:#b1add0;
}
.page .pre a:hover
{
background-color:#2d8da3;
display:block;
width:48px;
height:19px;
}
.page .next
{
width:48px;
height:22px;
display:block;
text-align:center;
border-style:solid;
border-width:1px;
border-color:#b1add0;
}
.page .next a:hover
{
background-color:#2d8da3;
display:block;
width:48px;
height:19px;
}
/*分頁(yè)部分 end*/
/*內(nèi)容部分 start*/
.content
{
width:700px;
height:120px;
border-style:solid;
border-width:1px;
border-color:#333333;
margin-bottom:10px;
}
.content_left
{
width:98px;
height:118px;
border-style:solid;
border-width:1px;
border-color:#333333;
float:left;
font-size:12px;
}
.content_right
{
margin-left:10px;
width:588px;
height:118px;
border-style:solid;
border-width:1px;
border-color:#0000ff;
float:left;
}
/*內(nèi)容部分 end*/
/style>
/head>
body>
form id="form1" runat="server">
div>
asp:Label ID="lbl1" runat="server">/asp:Label>!--放內(nèi)容-->
asp:Label ID="lbl2" runat="server">/asp:Label>!--放頁(yè)碼-->
/div>
/form>
/body>
/html>

css沒(méi)有用.css文件寫(xiě)是為了方便,呵呵……
二、再看下后臺(tái)代碼(因?yàn)槲沂怯萌龑訉?xiě)的,所以我會(huì)把BLL層、DAL層以及Models層的代碼也附上)
web(顯示)后臺(tái).cs代碼:
復(fù)制代碼 代碼如下:

public static int pageCount = 0;//總數(shù)可以用Session保存,避免每次都要查詢,影響速度
public int pageindex;
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
//page頁(yè)面索引,其他參數(shù)不變,默認(rèn)從第一頁(yè)開(kāi)始
JBLL.JManage manage = new JBLL.JManage();
pageCount = Convert.ToInt32(manage.GetCount().Tables[0].Rows[0]["num"].ToString());
if (Request.QueryString["page"] == null)
{
pageindex=1;
}
else
{
pageindex = Convert.ToInt32(Request.QueryString["page"].ToString());
}
//加載信息和頁(yè)面
GetInfo(pageindex, 10);
Paging(pageindex, 10);
}
}
/// summary>
/// 加載數(shù)據(jù)
/// /summary>
private void GetInfo(int pageindex, int size)
{
string strall = "";
int count;
ListJModels.JPerson> list = new JBLL.JManage().GetAllPerson(size, pageindex, "", out count);
StringBuilder sb = new StringBuilder();
foreach (JModels.JPerson p in list)
{
sb.Append("div class='content'>div class='content_left'>");
sb.Append(p.Name);
sb.Append("/div>div class='content_right'>");
sb.Append(p.Id.ToString());
sb.Append("/div>/div>");
}
strall = sb.ToString();
lbl1.Text = strall;
}
private void Paging(int pageindex, int size)
{
string strpage = "";
StringBuilder sb = new StringBuilder();
sb.Append("div class=\"page\">ul>");
//需要判斷是否啟用
if (pageindex == 1)
{
sb.Append("li class=\"pre\" style=\"display:none\">a href=\"Page.aspx?page=" + (pageindex - 1) + "\">lt;lt;Prev/a>/li>");
}
else
{
sb.Append("li class=\"pre\">a href=\"Page.aspx?page=" + (pageindex - 1) + "\">lt;lt;Prev/a>/li>");
}
//頁(yè)碼數(shù)
int pageNum;
if (pageCount % size == 0)
{
pageNum = pageCount / size;
}
else
{
pageNum = pageCount / size + 1;
}
if (pageNum 11)
{
for (int i = 1; i = pageNum; i++)
{
if (i == pageindex)
{
sb.Append("li>span>a href=\"Page.aspx?page=" + i + "\">" + i + "/a>/span>/li>");
}
else
{
sb.Append("li>a href=\"Page.aspx?page=" + i + "\">" + i + "/a>/li>");
}
}
}
else
{
//判斷是否是前7頁(yè)
if (pageindex > 0 pageindex 8)
{
for (int i = 1; i 9; i++)
{
if (i == pageindex)
{
sb.Append("li>span>a href=\"Page.aspx?page=" + i + "\">" + i + "/a>/span>/li>");
}
else
{
sb.Append("li>a href=\"Page.aspx?page=" + i + "\">" + i + "/a>/li>");
}
}
sb.Append("li class=\"point\">.../li>");
sb.Append("li>a href=\"Page.aspx?page=" + (pageNum - 1) + "\">" + (pageNum - 1) + "/a>/li>");
sb.Append("li>a href=\"Page.aspx?page=" + (pageNum) + "\">" + (pageNum) + "/a>/li>");
}
else if (pageindex > 7 pageindex (pageNum - 6))
{
sb.Append("li>a href=\"Page.aspx?page=1\">1/a>/li>");
sb.Append("li>a href=\"Page.aspx?page=2\">2/a>/li>");
sb.Append("li class=\"point\">.../li>");
sb.Append("li>a href=\"Page.aspx?page=" + (pageindex - 3) + "\">" + (pageindex - 3) + "/a>/li>");
sb.Append("li>a href=\"Page.aspx?page=" + (pageindex - 2) + "\">" + (pageindex - 2) + "/a>/li>");
sb.Append("li>a href=\"Page.aspx?page=" + (pageindex - 1) + "\">" + (pageindex - 1) + "/a>/li>");
sb.Append("li>span>a href=\"Page.aspx?page=" + pageindex + "\">" + pageindex + "/a>/span>/li>");
sb.Append("li>a href=\"Page.aspx?page=" + (pageindex + 1) + "\">" + (pageindex + 1) + "/a>/li>");
sb.Append("li>a href=\"Page.aspx?page=" + (pageindex + 2) + "\">" + (pageindex + 2) + "/a>/li>");
sb.Append("li class=\"point\">.../li>");
sb.Append("li>a href=\"Page.aspx?page=" + (pageNum - 1) + "\">" + (pageNum - 1) + "/a>/li>");
sb.Append("li>a href=\"Page.aspx?page=" + (pageNum) + "\">" + (pageNum) + "/a>/li>");
}
else
{
sb.Append("li>a href=\"Page.aspx?page=1\">1/a>/li>");
sb.Append("li>a href=\"Page.aspx?page=2\">2/a>/li>");
sb.Append("li class=\"point\">.../li>");
for (int i = (pageNum - 7); i = pageNum; i++)
{
if (i == pageindex)
{
sb.Append("li>span>a href=\"Page.aspx?page=" + i + "\">" + i + "/a>/span>/li>");
}
else
{
sb.Append("li>a href=\"Page.aspx?page=" + i + "\">" + i + "/a>/li>");
}
}
}
}
//需要判斷是否啟用
if (pageindex == pageNum)
{
sb.Append("li class=\"next\" style=\"display:none;\">a href=\"Page.aspx?page=" + (pageindex + 1) + "\">Nextgt;gt;/a>/li>");
}
else
{
sb.Append("li class=\"next\">a href=\"Page.aspx?page=" + (pageindex + 1) + "\">Nextgt;gt;/a>/li>");
}
sb.Append("/ul>/div>");
strpage = sb.ToString();
lbl2.Text = strpage;
}

BLL層(邏輯)代碼:
復(fù)制代碼 代碼如下:

public class JManage
{
public DataSet GetCount()
{
return JDAL.JService.GetCount();
}
///summary>
/// 記錄總條數(shù)
////summary>
///returns>/returns>
public DataSet GetCount(string where)
{
return JDAL.JService.GetCount(where);
}
///summary>
/// 得到所有人
////summary>
///returns>/returns>
public ListJModels.JPerson> GetAllPerson(int size, int index, string where, out int OutTotalCount)
{
return JDAL.JService.GetAllPerson(size, index, where, out OutTotalCount);
}
}

DAL層(數(shù)據(jù)處理)代碼:
復(fù)制代碼 代碼如下:

public static DataSet GetCount()
{
string sql = "select count(*) as num from qzDatas";
return DBHelp.GetDataSetBySql(sql);
}
///summary>
/// 記錄總條數(shù)
////summary>
///returns>/returns>
public static DataSet GetCount(string where)
{
string sql = "select count(*) as num from qzDatas where " + where + "";
return DBHelp.GetDataSetBySql(sql);
}
///summary>
/// 得到所有人
////summary>
///returns>/returns>
public static ListJModels.JPerson> GetAllPerson(int size, int index, string where, out int OutTotalCount)
{
JModels.JPerson person = null;
ListJModels.JPerson> list = new ListJModels.JPerson>();
DataTable dt = new DataTable();
string[] paramValue =
{
"qzDatas", //表明
"*", //返回字段
"qzDatasId", //主鍵標(biāo)識(shí)列
where, //where條件
"qzDatasId asc", //排序必須跟有 asc 或 desc
"1", //排序規(guī)則 1:正序asc 2:倒序desc 3:多列排序方法
"0", //記錄總數(shù) 0:會(huì)返回總記錄
""+size, //頁(yè)面大小
""+index //當(dāng)前頁(yè)
};
dt = DBHelp.SqlGetDataTable("P_AspNetPage", CommandType.StoredProcedure, paramValue, out OutTotalCount);
foreach (DataRow dr in dt.Rows)
{
person = new JModels.JPerson();
person.Id = Convert.ToInt32(dr["qzDatasId"]);
person.Name = dr["dataName"].ToString();
person.Imgurl = dr["url"].ToString();
person.Email = dr["dataName"].ToString();
list.Add(person);
}
return list;
}

Models層代碼:
復(fù)制代碼 代碼如下:

public class JPerson
{
//id
private int id;
public int Id
{
get { return id; }
set { id = value; }
}
//名字
private string name;
public string Name
{
get { return name; }
set { name = value; }
}
//頭像
private string imgurl;
public string Imgurl
{
get { return imgurl; }
set { imgurl = value; }
}
//Email
private string email;
public string Email
{
get { return email; }
set { email = value; }
}
}

以上代碼我都有注釋了,就不多解釋了,但我相信應(yīng)該還有改進(jìn)的地方,尤其是web顯示層的后臺(tái),添加頁(yè)碼那部分,肯定還有好辦法,如果誰(shuí)有好辦法,希望能告訴我啊,大家一起學(xué)習(xí)嘛,謝謝。
三、看一下存儲(chǔ)過(guò)程到底是怎么寫(xiě)的
復(fù)制代碼 代碼如下:

CREATE PROCEDURE [dbo].[P_AspNetPage]
/*
nzperfect [no_mIss] 高效通用分頁(yè)存儲(chǔ)過(guò)程(雙向檢索) 2007.5.7 QQ:34813284
敬告:適用于單一主鍵或存在唯一值列的表或視圖
ps:Sql語(yǔ)句為8000字節(jié),調(diào)用時(shí)請(qǐng)注意傳入?yún)?shù)及sql總長(zhǎng)度不要超過(guò)指定范圍
*/
@TableName VARCHAR(200), --表名
@FieldList VARCHAR(2000), --顯示列名,如果是全部字段則為*
@PrimaryKey VARCHAR(100), --單一主鍵或唯一值鍵
@Where VARCHAR(2000), --查詢條件 不含'where'字符,如id>10 and len(userid)>9
@Order VARCHAR(1000), --排序 不含'order by'字符,如id asc,userid desc,必須指定asc或desc
--注意當(dāng)@SortType=3時(shí)生效,記住一定要在最后加上主鍵,否則會(huì)讓你比較郁悶
@SortType INT, --排序規(guī)則 1:正序asc 2:倒序desc 3:多列排序方法
@RecorderCount INT, --記錄總數(shù) 0:會(huì)返回總記錄
@PageSize INT, --每頁(yè)輸出的記錄數(shù)
@PageIndex INT, --當(dāng)前頁(yè)數(shù)
@TotalCount INT OUTPUT, --記返回總記錄
@TotalPageCount INT OUTPUT --返回總頁(yè)數(shù)
AS
SET NOCOUNT ON
IF ISNULL(@TotalCount,'') = '' SET @TotalCount = 0
SET @Order = RTRIM(LTRIM(@Order))
SET @PrimaryKey = RTRIM(LTRIM(@PrimaryKey))
SET @FieldList = REPLACE(RTRIM(LTRIM(@FieldList)),'','')
WHILE CHARINDEX(', ',@Order) > 0 OR CHARINDEX(' ,',@Order) > 0
BEGIN
SET @Order = REPLACE(@Order,', ',',')
SET @Order = REPLACE(@Order,' ,',',')
END
IF ISNULL(@TableName,'') = '' OR ISNULL(@FieldList,'') = ''
OR ISNULL(@PrimaryKey,'') = ''
OR @SortType 1 OR @SortType >3
OR @RecorderCount 0 OR @PageSize 0 OR @PageIndex 0
BEGIN
PRINT('ERR_00')
RETURN
END
IF @SortType = 3
BEGIN
IF (UPPER(RIGHT(@Order,4))!=' ASC' AND UPPER(RIGHT(@Order,5))!=' DESC')
BEGIN PRINT('ERR_02') RETURN END
END
DECLARE @new_where1 VARCHAR(1000)
DECLARE @new_where2 VARCHAR(1000)
DECLARE @new_order1 VARCHAR(1000)
DECLARE @new_order2 VARCHAR(1000)
DECLARE @new_order3 VARCHAR(1000)
DECLARE @Sql VARCHAR(8000)
DECLARE @SqlCount NVARCHAR(4000)
IF ISNULL(@where,'') = ''
BEGIN
SET @new_where1 = ''
SET @new_where2 = ' WHERE '
END
ELSE
BEGIN
SET @new_where1 = ' WHERE ' + @where
SET @new_where2 = ' WHERE ' + @where + ' AND '
END
IF ISNULL(@order,'') = '' OR @SortType = 1 OR @SortType = 2
BEGIN
IF @SortType = 1
BEGIN
SET @new_order1 = ' ORDER BY ' + @PrimaryKey + ' ASC'
SET @new_order2 = ' ORDER BY ' + @PrimaryKey + ' DESC'
END
IF @SortType = 2
BEGIN
SET @new_order1 = ' ORDER BY ' + @PrimaryKey + ' DESC'
SET @new_order2 = ' ORDER BY ' + @PrimaryKey + ' ASC'
END
END
ELSE
BEGIN
SET @new_order1 = ' ORDER BY ' + @Order
END
IF @SortType = 3 AND CHARINDEX(','+@PrimaryKey+'',','+@Order)>0
BEGIN
SET @new_order1 = ' ORDER BY ' + @Order
SET @new_order2 = @Order + ','
SET @new_order2 = REPLACE(REPLACE(@new_order2,'ASC,','{ASC},'),'DESC,','{DESC},')
SET @new_order2 = REPLACE(REPLACE(@new_order2,'{ASC},','DESC,'),'{DESC},','ASC,')
SET @new_order2 = ' ORDER BY ' + SUBSTRING(@new_order2,1,LEN(@new_order2)-1)
IF @FieldList > '*'
BEGIN
SET @new_order3 = REPLACE(REPLACE(@Order + ',','ASC,',','),'DESC,',',')
SET @FieldList = ',' + @FieldList
WHILE CHARINDEX(',',@new_order3)>0
BEGIN
IF CHARINDEX(SUBSTRING(','+@new_order3,1,CHARINDEX(',',@new_order3)),','+@FieldList+',')>0
BEGIN
SET @FieldList =
@FieldList + ',' + SUBSTRING(@new_order3,1,CHARINDEX(',',@new_order3))
END
SET @new_order3 =
SUBSTRING(@new_order3,CHARINDEX(',',@new_order3)+1,LEN(@new_order3))
END
SET @FieldList = SUBSTRING(@FieldList,2,LEN(@FieldList))
END
END
SET @SqlCount = 'SELECT @TotalCount=COUNT(*),@TotalPageCount=CEILING((COUNT(*)+0.0)/'
+ CAST(@PageSize AS VARCHAR)+') FROM ' + @TableName + @new_where1
IF @RecorderCount = 0
BEGIN
EXEC SP_EXECUTESQL @SqlCount,N'@TotalCount INT OUTPUT,@TotalPageCount INT OUTPUT',
@TotalCount OUTPUT,@TotalPageCount OUTPUT
END
ELSE
BEGIN
SELECT @TotalCount = @RecorderCount
END
IF @PageIndex > CEILING((@TotalCount+0.0)/@PageSize)
BEGIN
SET @PageIndex = CEILING((@TotalCount+0.0)/@PageSize)
END
IF @PageIndex = 1 OR @PageIndex >= CEILING((@TotalCount+0.0)/@PageSize)
BEGIN
IF @PageIndex = 1 --返回第一頁(yè)數(shù)據(jù)
BEGIN
SET @Sql = 'SELECT TOP ' + STR(@PageSize) + '' + @FieldList + ' FROM '
+ @TableName + @new_where1 + @new_order1
END
IF @PageIndex >= CEILING((@TotalCount+0.0)/@PageSize) --返回最后一頁(yè)數(shù)據(jù)
BEGIN
SET @Sql = 'SELECT TOP ' + STR(@PageSize) + '' + @FieldList + ' FROM ('
+ 'SELECT TOP ' + STR(ABS(@PageSize*@PageIndex-@TotalCount-@PageSize))
+ '' + @FieldList + ' FROM '
+ @TableName + @new_where1 + @new_order2 + ' ) AS TMP '
+ @new_order1
END
END
ELSE
BEGIN
IF @SortType = 1 --僅主鍵正序排序
BEGIN
IF @PageIndex = CEILING((@TotalCount+0.0)/@PageSize)/2 --正向檢索
BEGIN
SET @Sql = 'SELECT TOP ' + STR(@PageSize) + '' + @FieldList + ' FROM '
+ @TableName + @new_where2 + @PrimaryKey + ' > '
+ '(SELECT MAX(' + @PrimaryKey + ') FROM (SELECT TOP '
+ STR(@PageSize*(@PageIndex-1)) + '' + @PrimaryKey
+ ' FROM ' + @TableName
+ @new_where1 + @new_order1 +' ) AS TMP) '+ @new_order1
END
ELSE --反向檢索
BEGIN
SET @Sql = 'SELECT TOP ' + STR(@PageSize) + '' + @FieldList + ' FROM ('
+ 'SELECT TOP ' + STR(@PageSize) + ''
+ @FieldList + ' FROM '
+ @TableName + @new_where2 + @PrimaryKey + ' '
+ '(SELECT MIN(' + @PrimaryKey + ') FROM (SELECT TOP '
+ STR(@TotalCount-@PageSize*@PageIndex) + '' + @PrimaryKey
+ ' FROM ' + @TableName
+ @new_where1 + @new_order2 +' ) AS TMP) '+ @new_order2
+ ' ) AS TMP ' + @new_order1
END
END
IF @SortType = 2 --僅主鍵反序排序
BEGIN
IF @PageIndex = CEILING((@TotalCount+0.0)/@PageSize)/2 --正向檢索
BEGIN
SET @Sql = 'SELECT TOP ' + STR(@PageSize) + '' + @FieldList + ' FROM '
+ @TableName + @new_where2 + @PrimaryKey + ' '
+ '(SELECT MIN(' + @PrimaryKey + ') FROM (SELECT TOP '
+ STR(@PageSize*(@PageIndex-1)) + '' + @PrimaryKey
+' FROM '+ @TableName
+ @new_where1 + @new_order1 + ') AS TMP) '+ @new_order1
END
ELSE --反向檢索
BEGIN
SET @Sql = 'SELECT TOP ' + STR(@PageSize) + '' + @FieldList + ' FROM ('
+ 'SELECT TOP ' + STR(@PageSize) + ''
+ @FieldList + ' FROM '
+ @TableName + @new_where2 + @PrimaryKey + ' > '
+ '(SELECT MAX(' + @PrimaryKey + ') FROM (SELECT TOP '
+ STR(@TotalCount-@PageSize*@PageIndex) + '' + @PrimaryKey
+ ' FROM ' + @TableName
+ @new_where1 + @new_order2 +' ) AS TMP) '+ @new_order2
+ ' ) AS TMP ' + @new_order1
END
END
IF @SortType = 3 --多列排序,必須包含主鍵,且放置最后,否則不處理
BEGIN
IF CHARINDEX(',' + @PrimaryKey + '',',' + @Order) = 0
BEGIN PRINT('ERR_02') RETURN END
IF @PageIndex = CEILING((@TotalCount+0.0)/@PageSize)/2 --正向檢索
BEGIN
SET @Sql = 'SELECT TOP ' + STR(@PageSize) + '' + @FieldList + ' FROM ( '
+ 'SELECT TOP ' + STR(@PageSize) + '' + @FieldList + ' FROM ( '
+ ' SELECT TOP ' + STR(@PageSize*@PageIndex) + '' + @FieldList
+ ' FROM ' + @TableName + @new_where1 + @new_order1 + ' ) AS TMP '
+ @new_order2 + ' ) AS TMP ' + @new_order1
END
ELSE --反向檢索
BEGIN
SET @Sql = 'SELECT TOP ' + STR(@PageSize) + '' + @FieldList + ' FROM ( '
+ 'SELECT TOP ' + STR(@PageSize) + '' + @FieldList + ' FROM ( '
+ ' SELECT TOP ' + STR(@TotalCount-@PageSize *@PageIndex+@PageSize) + '' + @FieldList
+ ' FROM ' + @TableName + @new_where1 + @new_order2 + ' ) AS TMP '
+ @new_order1 + ' ) AS TMP ' + @new_order1
END
END
END
EXEC(@Sql)

存儲(chǔ)過(guò)程應(yīng)該寫(xiě)得很詳細(xì)了...我就不解釋了。這個(gè)存儲(chǔ)過(guò)程的用處很多啊,如果想實(shí)現(xiàn)無(wú)刷新的分頁(yè)的話也是可以用的,調(diào)用的方法基本一樣,大家可以自己試試。
  好吧,到這里代碼也基本上完成了,我認(rèn)為主要的還是思路問(wèn)題,思路有了就好辦了,代碼如果哪里有誤或者有哪些更好的解決方案,請(qǐng)告訴我啊,一定虛心學(xué)習(xí)哈。下面看下效果圖吧!效果圖如下:

有一個(gè)注意點(diǎn)哦:進(jìn)入頁(yè)面的時(shí)候一定要給參數(shù)page一個(gè)值,不然的話,會(huì)出錯(cuò),你懂的呀!如:http://localhost:60284/Page.aspx?page=88
您可能感興趣的文章:
  • asp.net實(shí)現(xiàn)調(diào)用帶有輸出參數(shù)的存儲(chǔ)過(guò)程實(shí)例
  • asp.net中調(diào)用oracle存儲(chǔ)過(guò)程的方法
  • asp.net中IDataParameter調(diào)用存儲(chǔ)過(guò)程的實(shí)現(xiàn)方法
  • asp.net安全、實(shí)用、簡(jiǎn)單的大容量存儲(chǔ)過(guò)程分頁(yè)
  • asp.net 結(jié)合mysql存儲(chǔ)過(guò)程進(jìn)行分頁(yè)代碼
  • 在ASP.NET中用存儲(chǔ)過(guò)程執(zhí)行SQL語(yǔ)句
  • asp.net 存儲(chǔ)過(guò)程調(diào)用
  • asp.net sql存儲(chǔ)過(guò)程
  • Asp .net 調(diào)用帶參數(shù)的存儲(chǔ)過(guò)程

標(biāo)簽:常州 孝感 許昌 西雙版納 自貢 信陽(yáng) 萊蕪 朔州

巨人網(wǎng)絡(luò)通訊聲明:本文標(biāo)題《asp.net利用存儲(chǔ)過(guò)程和div+css實(shí)現(xiàn)分頁(yè)(類似于博客園首頁(yè)分頁(yè))》,本文關(guān)鍵詞  asp.net,利用,存儲(chǔ),過(guò)程,和,;如發(fā)現(xiàn)本文內(nèi)容存在版權(quán)問(wèn)題,煩請(qǐng)?zhí)峁┫嚓P(guān)信息告之我們,我們將及時(shí)溝通與處理。本站內(nèi)容系統(tǒng)采集于網(wǎng)絡(luò),涉及言論、版權(quán)與本站無(wú)關(guān)。
  • 相關(guān)文章
  • 下面列出與本文章《asp.net利用存儲(chǔ)過(guò)程和div+css實(shí)現(xiàn)分頁(yè)(類似于博客園首頁(yè)分頁(yè))》相關(guān)的同類信息!
  • 本頁(yè)收集關(guān)于asp.net利用存儲(chǔ)過(guò)程和div+css實(shí)現(xiàn)分頁(yè)(類似于博客園首頁(yè)分頁(yè))的相關(guān)信息資訊供網(wǎng)民參考!
  • 推薦文章