ListView的高效分頁

來源:互聯網
上載者:User

標籤:blog   資料   art   ar   代碼   div   資料庫   log   

需要在DataSet中設定兩個sql查詢

1.根據參數查詢指定頁的資料

select *from(select id,name,age,over(order by id)rownamfrom table where id>30)twhere t.rownam>@startRowIndex and t.rownam<[email protected][email protected]

這裡注意!因為DataSet編輯器對over()函數不支援,所以要手動添加parameter設定參數

@startRowIndex,@maximumRows這兩個參數名是指定的,一般不變。

 

2.查詢資料庫中的總資料個數count

select count(*)from table

然後先按照正常流程添加ObjectDataSource(這裡必須選擇getData()函數,不然ListView找無法配置資料來源),ListView(編輯,插入,刪除,分頁)

配置好後回到aspx字碼頁面

將ObjectDataSource的SelectMethod設定為取得分頁資料的方法,SelectCountMethod設定為取得行數的方法,EnablePaging設為true

讓分頁後的導航顯示頁數在中間的方法

在頁數標籤前後放置各一個翻頁標籤,然後前面的翻頁標籤隱藏“下一頁”,“尾頁”,後面的翻頁標籤隱藏“前一頁”,“首頁”。

 

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

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.