jquery-based paging control (C #) _jquery

Source: Internet
Author: User
Tags eval prev
JS Code:
Code:
Copy Code code as follows:

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 + + <a href= ' # ' style= ' font-size:14px;color:red ' > ' + curpage + ' </a> ';
}
else {
Strpage + + "<a href=\" #\ "style= ' font-size:14px ' onclick=\" "+ _funname +" ("+ Curpage +"); \ ">" + curpage + " ;/a> ";
}
if (curpage = = MaxSize && _maxpagesize-_currentpagesize-1 > size) {
Strpage + = "... ";
}
Strresult + = Strpage;
}
}
Strresult + = "";
if (_isupdown) {
if (_currentpagesize = 1)
strresult = "<a href= ' # ' > Prev </a>" + strresult;
Else
strresult = "<a href=\" #\ "onclick=\" "+ _funname +" ("+ (_currentpagesize-1) +"); \ "> Prev </a>" + strresu Lt
if (_currentpagesize = = _maxpagesize) {
strresult = strresult + "<a> next page </a></ul>";
}
else {
strresult = strresult + "<a href=\" #\ "onclick=\" "+ _funname +" ("+ (_currentpagesize + 1) +") > next page </a&gt ;";
}
}
document.getElementById (objdiv). InnerHTML =strresult;
}

HTML Code:
Copy Code code as follows:

<script src= "Js/pageviewjs.js" type= "Text/javascript" ></script>
<script language= "javascript" type= "Text/javascript" >
function Getcurpage (curpage) {
Take current page information
Document.forms[0].action = "Chrisblessinglist.aspx?" Page= "+ curpage;
Document.forms[0].submit ();
}
</script>
<body>
<form id= "Form1" runat= "Server" >
<div style= "WIDTH:1002PX; margin:0 auto; " >
<div id= "Hdgz" ></div>
<div id= "Liebiao" >
<div class= "a_01" id= "Container" >
<ul class= "LB" >
<asp:datalist id= "ddlblessinglist" runat= "Server" width= "100%" >
<ItemTemplate>
<li class= "BG01" >
<table width= "border=" 0 "cellspacing=" 0 "cellpadding=" 0 ">
<tr>
&LT;TD width= "height=" rowspan= "2" >

</td>
&LT;TD width= "align=" "left" valign= "Middle" class= "font_07" >
<% #Eval ("user_name")%>
To
<% #Eval ("To_username")%> "said:
</td>
</tr>
<tr>
&LT;TD align= "left" valign= "Top" "class=" font_07 "style=" Word-break:break-all; width:600px;
Overflow:auto; " >
<% #Eval ("To_context")%>
</td>
</tr>
</table>
</li>
</ItemTemplate>
</asp:DataList>
</ul>
</div>
<div class= "FY" >
<div id= "Divpage" >
</div>
</div>
</div>
<div id= "Back_zhufu" >
</div>
</div>
</div>
<asp:literal id= "Ltscript" runat= "Server" ></asp:Literal>
</form>
</body>

C # Code:
Copy Code code as follows:

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 = "<script language=\" javascript\ "type=\" text/javascript\ ">initpage" (\ "GetCurPage\", "+ page +", " + _maxpagesize + ", 8, true); ShowPage (\ "divpage\");</script> ";
}
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 statement:
Select Row_num,user_name,user_email,user_phone,to_username,to_context from (select Row_number ()-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 Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.