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.