Code
Public Static String Pagestrout ( Double Pagesize, Int Curpage, Double Rscount, String Pagepara)
{
Double Pagecountdouble = Rscount / Pagesize;
Int Pagecount = Convert. toint32 (math. Ceiling (pagecountdouble ));
If (Pagecount < 1 ) {Pagecount = 1 ;}
If (Curpage < 1 ) {Curpage = 1 ;}
If (Curpage > Pagecount) {curpage = Pagecount ;}
Int Pagelistnum = 10 ;
Int Step = 5 ;
Int Prepage = Curpage - 1 ;
Int Nextpage = Curpage + 1 ;
Int Pagefromnum = Curpage - Step;
Int Pageendnum = Curpage + Step;
If (Pagecount < Step)
{
Pagefromnum = 1 ;
Pageendnum = Pagecount;
} Else If (Pagecount < Pagelistnum)
{
Pagefromnum = 1 ;
Pageendnum = Pagecount;
} Else If (Pageendnum > Pagecount)
{
Pageendnum = Pagecount;
If (Pageendnum - Pagefromnum) < Pagelistnum)
{Pagefromnum = Pageendnum - Pagelistnum + 1 ;}
} Else
{
If (Pagefromnum < 1 )
{
Pagefromnum = 1 ;
Pageendnum = Curpage + Step - 1 ;
}
}
Stringbuilder pagestr = New Stringbuilder ();
// Pagestr. append ("<style>. pageclass {font-family: verdana, Arial, Helvetica, sans-serif; font-size: 11px; padding-top: 0px; text-align: Left; margin-top: 2px ;}");
Pagestr. append ( " <Style> " );
Pagestr. append ( " . Pageclass ul {float: Left; margin: 5px ;} " );
Pagestr. append ( " . Pageclass ul Li {margin-Right: 3px; float: Left ;} " );
Pagestr. append ( " . Pageclass ul Li a {border: 1px solid # d8dfef; color: # 01669a; text-Decoration: none; padding: 1px 4px; width: 20px; Height: 15px ;} " );
Pagestr. append ( " . Pageclass {font-family: verdana, Arial, Helvetica, sans-serif; font-size: 11px; padding-top: 0px; text-align: Left; margin-top: 2px ;} " );
Pagestr. append ( " . Pageclass ul Li A: hover {color: # fe6601; text-Decoration: none; Border: 1px solid # d8dfef; padding: 1px 4px; Height: 18px ;} " );
Pagestr. append ( " </Style> " );
Pagestr. append ( " <Div class = \ " Pageclass \ " > " );
Pagestr. append ( " <Ul> " );
Pagestr. append ( " <Li> <strong> " + Curpage + " / " + Pagecount + " & Nbsp; </strong> </LI> " );
Pagestr. append ( " </Ul> " );
If (Curpage ! = 1 ){
Pagestr. append ( " <Ul> " );
Pagestr. append ( " <Li> " );
Pagestr. append ( " <A href =? Curpage = 1 " + Pagepara + " > Homepage </a> & nbsp; <a href =? Curpage = 1 & " + Pagepara + " > Previous page </a> " );
Pagestr. append ( " </LI> " );
Pagestr. append ( " </Ul> " );
}
Pagestr. append ( " <Ul> " );
For ( Int I = Pagefromnum; I <= Pageendnum; I ++ )
{
Pagestr. append ( " <Li> " );
If (Curpage = I)
{Pagestr. append (I. tostring ());}
Else
{
Pagestr. append ( " <A href =? Curpage = " + I. tostring () + "" + Pagepara + " > " + I. tostring () + " </A> " );
}
Pagestr. append ( " </LI> " );
}
Pagestr. append ( " </Ul> " );
If (Curpage ! = Pagecount)
{
Pagestr. append ( " <Ul> <li> " );
Pagestr. append ( " <A href =? Curpage = " + Nextpage + " & " + Pagepara + " > Next page </a> & nbsp; <a href =? Curpage = " + Pagecount + " & " + Pagepara + " > Last page </a> " );
Pagestr. append ( " </LI> </ul> " );
}
Pagestr. append ( " </Div> " );
Return Pagestr. tostring ();
}
As shown above, pagesize is the number of items to be explicitly displayed on each page. curpage indicates the current page, rscount indicates the total number of records, and pagepara indicates the parameters at the end of the page,
Suppose the page is www.gosoa.com.cn/index.aspx? Searchtype = A & keyword = 'gosoa ', pagepara =Searchtype = A & keyword = 'gosoa'
OK. If you have any questions, leave a message.