Home > Web Front-end > JS Tutorial > Paging control based on jquery (C#)_jquery

Paging control based on jquery (C#)_jquery

WBOY
Release: 2016-05-16 18:12:30
Original
1320 people have browsed it

JS代码:
Code:

复制代码 代码如下:

var _MaxPageSize = 0;
var _PageSize = 5;
var _IsUpDown = false;
function InitPage(funName, currentPageSize, maxPageSize, pageSize, isUpDown) {
_FunName = funName;
_CurrentPageSize = currentPageSize;
_MaxPageSize = maxPageSize;
_PageSize = pageSize;
_IsUpDown = isUpDown;
}
function ShowPage(objDiv) {
var strResult = "";
var size = Math.floor(_PageSize / 2);
var maxSize = _CurrentPageSize size > _MaxPageSize ? _MaxPageSize : _CurrentPageSize size;
var minSize = _CurrentPageSize - size < 1 ? 1 : _CurrentPageSize - size;
if (maxSize == _MaxPageSize)
minSize = maxSize - _PageSize 1;
if (minSize == 1)
maxSize = minSize _PageSize - 1;
var str = "";
for (var i = 0; i < _MaxPageSize; i ) {
var curPage = i 1;
if (curPage == 1 || (curPage >= minSize && curPage <= maxSize) || curPage == _MaxPageSize) {
var strPage = "";
if (curPage == minSize && (_CurrentPageSize > _PageSize || minSize > 2))
strPage = "... ";
if (_CurrentPageSize == curPage) {
strPage = "   " curPage "";
}
else {
strPage = "  " curPage "";
}
if (curPage == maxSize && _MaxPageSize - _CurrentPageSize - 1 > size) {
strPage = "... ";
}
strResult = strPage;
}
}
strResult = "";
if (_IsUpDown) {
if (_CurrentPageSize == 1)
strResult = "上一页" strResult;
else
strResult = "   上一页" strResult;
if (_CurrentPageSize == _MaxPageSize) {
strResult = strResult "  下一页";
}
else {
strResult = strResult "   下一页";
}
}
document.getElementById(objDiv).innerHTML =strResult;
}

HTML Code:
复制代码 代码如下:

























  • <%#Eval("User_Name")%>
    对 【
    <%#Eval("To_UserName")%>】说:

        <%#Eval("To_Context")%>




















C# Code:
复制代码 代码如下:

private int _MaxPageSize = 1;
protected void Page_Load(object sender, EventArgs e)
{
int page = 1;
if (Request.QueryString["Page"] != null && Request.QueryString["Page"].ToString() != "")
{
page = Convert.ToInt32(Request.QueryString["Page"]);
}
int _PageSize = 5;
BindChristData(page, _PageSize);
ltScript.Text = "";
}
private void BindChristData(int pageIndex, int pageSize)
{
int intStartIndex = (pageIndex - 1) * pageSize 1;
int intEndIndex = pageIndex * pageSize;
DataSet tChrisTable = TChristmaxWishBLL.GetTChristmaxWish(intStartIndex, intEndIndex);
if (tChrisTable != null && tChrisTable.Tables[0].Rows.Count > 0)
{
ddlBlessingList.DataSource = tChrisTable;
ddlBlessingList.DataBind();
_MaxPageSize = Convert.ToInt32(tChrisTable.Tables[1].Rows[0][0].ToString()) % pageSize == 0 ? Convert.ToInt32(tChrisTable.Tables[1].Rows[0][0].ToString()) / pageSize : Convert.ToInt32(tChrisTable.Tables[1].Rows[0][0].ToString()) / pageSize 1;
}
}
Sql语句:
select row_num,User_Name,User_Email,User_Phone,To_UserName,To_Context from(SELECT ROW_NUMBER() OVER ( ORDER BY To_Date desc)as row_num,User_Name,User_Email,User_Phone,To_UserName,To_Context from TChristmaxWish where Is_Del=0 )as newTable where row_num between @intStrIndex and @intEndIndex;
select count(id) from TChristmaxWish where Is_Del=0
Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template