1、行命令處理
(1、 后臺(tái)代碼:操作行
//如果是來自html響應(yīng)中的該函數(shù)操作
if(e.CommandName=="addAge"){
//取得行號(hào)
int index=((ListViewDataItem)e.Item)DispalyIndex;
//取得當(dāng)前操作行的主鍵值
//DataKeys存的是所有ID,取的是第index個(gè)ID
Guid id=(Guid)ListView1.DataKeys[index].Value;
表Adapter adapter=new 表Adapter();
adpter.自定義數(shù)據(jù)庫函數(shù)addAge;
//數(shù)據(jù)綁定
ListView.DataBing();
}
(2、排序
CommandName="Sort"
CommandArgument="ID"
內(nèi)部排序,效率較低
2、DataPager 分頁
PageControlID:給哪個(gè)ListView分頁
高級(jí)分頁:
查詢子查詢
select* from
(Select id,name,age,row_number() over(order by id)rownum from T_Users)t
where t.rownum>11and t.rownum20
3、高效分頁:
(1、數(shù)據(jù)庫方法:
//獲取本頁的行數(shù)
開始的行數(shù):startRowIndex
開始加本頁的行數(shù):startRowIndex+maximumRows
//數(shù)據(jù)庫方法:GetCount
select Count(*)from T_Users
//數(shù)據(jù)庫方法名:QueryCount
select* from
(
select Id ,Name,Gender,Row_Number() over(order by Id)rownum FROM dbo.T_User
)t
where t.rownum>@startRowIndex and t.rowRow=@startRowIndex+@maximumRows
由于startRowIndex+maximumRows兩個(gè)參數(shù)不會(huì)幫我們生成,需要我們自己手動(dòng)添加。
(2、頁面
**不要SelectParameters>
**增加一個(gè)SelectCountMethod="QueryCount"設(shè)置取得行數(shù)的方法
而SelectMethod="GetPageData"是取得分頁信息
而EnablePaging="true"
**先按正常流程配置ListView的objectDataSource,讓ListVIew自動(dòng)生成
再去配置分頁數(shù)據(jù)源
您可能感興趣的文章:- asp.net Repeater分頁實(shí)例(PageDataSource的使用)
- asp.net Gridview分頁保存選項(xiàng)
- asp.net自定義分頁控件示例
- asp.net中利用Jquery+Ajax+Json實(shí)現(xiàn)無刷新分頁的實(shí)例代碼
- asp.net 使用js分頁實(shí)現(xiàn)異步加載數(shù)據(jù)
- Asp.Net其他頁面如何調(diào)用Web用戶控件寫的分頁
- asp.net實(shí)現(xiàn)access數(shù)據(jù)庫分頁的方法
- ASP.NET MVC 5使用X.PagedList.Mvc進(jìn)行分頁教程(PagedList.Mvc)
- asp.net中的GridView分頁問題
- asp.net gridview分頁:第一頁 下一頁 1 2 3 4 上一頁 最末頁
- asp.net實(shí)現(xiàn)簡(jiǎn)單分頁實(shí)例
- 簡(jiǎn)單好用的ASP.NET分頁類(支持AJAX、自定義文字)
- asp.net中如何調(diào)用sql存儲(chǔ)過程實(shí)現(xiàn)分頁
- ASP.NET無刷新分頁簡(jiǎn)單實(shí)現(xiàn)
- asp.net分頁功能實(shí)現(xiàn)