JS Code:
Code:
Copy codeThe Code is 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 = '#'> previous page </a>" + strResult;
Else
StrResult = "<a href = \" # \ "onclick = \" "+ _ FunName +" ("+ (_ CurrentPageSize-1) + "); \ "> previous page </a>" + strResult;
If (_ CurrentPageSize = _ MaxPageSize ){
StrResult = strResult + "<a> next page </a> </ul> ";
}
Else {
StrResult = strResult + "<a href = \" # \ "onclick = \" "+ _ FunName +" ("+ (_ CurrentPageSize + 1) + "); \ "> next page </a> ";
}
}
Document. getElementById (objDiv). innerHTML = strResult;
}
HTML Code:
Copy codeThe Code is as follows:
<Script src = "js/PageViewJS. js" type = "text/javascript"> </script>
<Script language = "javascript" type = "text/javascript">
Function GetCurPage (curPage ){
// Obtain the information on the current page
Document. forms [0]. action = "ChrisBlessingList. aspx? Page = "+ curPage;
Document. forms [0]. submit ();
}
</Script>
</Head>
<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 = "700" border = "0" cellspacing = "0" cellpadding = "0">
<Tr>
<Td width = "100" height = "90" rowspan = "2">
</Td>
<Td width = "600" align = "left" valign = "middle" class = "font_07">
<% # Eval ("User_Name") %>
To 【
<% # Eval ("To_UserName") %>:
</Td>
</Tr>
<Tr>
<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>
</Html>
C # Code:
Copy codeThe Code is 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 () 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