On the Wap page, use asp.net to move the Control List page.

Source: Internet
Author: User

 

1. 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 ;}}
}

Ii. Paging
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 (); // The total number of records
Int totalPage = 0; // total number of 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 szhotline where atype =" + atype + "and bkcity =" + bkcity + "order by bookid desc) order by bookid asc ";
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;
Note: dbAccess is a class for user-defined database operations, because the database uses Access. Select top n * from (select * m from table order by id desc) order by id desc is used to adjust the pages of m and n parameters.



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.