国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 編程 > .NET > 正文

Wap頁面使用asp.net中移動控件List分頁

2024-07-10 12:56:14
字體:
來源:轉載
供稿:網友
注冊會員,創建你的web開發資料庫, 

一、創建一個類
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; } }
}

二、分頁
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()); //總記錄數
int totalpage = 0; //總頁數
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;
說明:其中dbaccess是自定義的操作數據庫的類,由于數據庫使用的是access。采用的分頁采用了select top n * from (select * m from table order by id desc) order by id desc的方式,調整m,n兩個參數分頁。


發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 呼图壁县| 夏津县| 大新县| 永和县| 彝良县| 宝清县| 克山县| 库车县| 望江县| 伊春市| 大方县| 忻城县| 宝清县| 鄂州市| 高碑店市| 奉新县| 博乐市| 大冶市| 卢龙县| 镇康县| 游戏| 临西县| 抚宁县| 宜春市| 外汇| 宁明县| 鹿泉市| 绥滨县| 乌鲁木齐市| 和顺县| 广平县| 五家渠市| 宁津县| 重庆市| 壤塘县| 白银市| 湖北省| 罗甸县| 嫩江县| 焦作市| 山东|