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.