WAP pages use ASP.net to move controls list paging

Source: Internet
Author: User
Tags tostring trim
asp.net| Pagination | controls | page

First, create a class
public class navigation
{
private string _sitename, _siteurl;
Public navigation (String siteName, String siteurl)
{
_sitename = SiteName;
_siteurl = SiteURL;
}
public string SiteName {get {return _sitename;}}
public string SiteURL {get {return _siteurl;}}
}

Second, pagination
DbAccess mydb = new dbAccess ();
MyDB. SQLSTR = "SELECT count (BookID) as Totalid from Szhotline where bkcity= '" + bkcity + "' and atype=" + atype;
DataSet dstotal = mydb.readtable ("Szhotline");
int counttotal = Convert.ToInt32 (dstotal.tables["Szhotline"). rows[0]["Totalid"]. ToString ()); Total number of records
int totalpage = 0; Total pages
if (counttotal% perpage = 0)
Totalpage = Convert.ToInt16 (counttotal/perpage);
Else
Totalpage = Convert.ToInt16 (counttotal/perpage) + 1;

int Cp_n, cp_p;
if (Cur_page > 1)
Cp_p = cur_page-1;
Else
Cp_p = 1;

If (Cur_page < totalpage)
Cp_n = cur_page + 1;
else
Cp_n = totalpage;

Link_p.navigateurl = "szhotline.aspx?page_c=" + cp_p + "&bkcity=" + bkcity + "&atype=" + atype;
Link_n.navigateurl = "szhotline.aspx?page_c=" + cp_n + "&bkcity=" + bkcity + "&atype=" + atype;
list1.datatextfield= "SiteName";
list1.datavaluefield= "SiteURL";
ArrayList arr = new ArrayList ();
MyDB. SQLSTR = "SELECT top" + Perpage + "* FROM (select top" + perpage*convert.toint16 (cur_page) + "Bookid,bookname from Szh Otline where atype= "+ Atype +" and bkcity= ' "+ bkcity +" ' ORDER by BookID-desc "ORDER by bookid ASC"; The
DataSet myds = mydb.readtable ("Szhotline");
for (int i=0; I {
string bkname = myDS. tables["Szhotline"]. rows["BookName"]. ToString (). Trim ();
String bkurl = "szhotdet.aspx?bookid=" + myds. tables["Szhotline"]. rows["BookID"]. ToString (). Trim ();
Arr. ADD (new Navigation (Bkname, Bkurl));
}
List1.datasource = arr;
List1.itemsaslinks = true;
List1.databind ();

ActiveForm = list;
Description: Where dbaccess is a custom action database class, because the database is using Access. The paging of the M,n two parameters is adjusted by using the desc of select top N * FROM (SELECT * m) to the ORDER by id Desc.




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.