欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

ASP.NET筆記之 行命令處理與分頁詳解

 更新時間:2013年04月23日 11:19:17   作者:  
本篇文章小編為大家介紹,ASP.NET筆記之 行命令處理與分頁詳解。需要的朋友參考下

1、行命令處理

(1、 后臺代碼:操作行

//如果是來自html響應(yīng)中的該函數(shù)操作
if(e.CommandName=="addAge"){

//取得行號
int index=((ListViewDataItem)e.Item)DispalyIndex;
//取得當(dāng)前操作行的主鍵值
//DataKeys存的是所有ID,取的是第index個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:給哪個ListView分頁



高級分頁:



查詢子查詢
select* from
(Select id,name,age,row_number() over(order by id)rownum from T_Users)t
where t.rownum>11and t.rownum<20


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兩個參數(shù)不會幫我們生成,需要我們自己手動添加。

(2、頁面

**不要<SelectParameters>
**增加一個SelectCountMethod="QueryCount"設(shè)置取得行數(shù)的方法
而SelectMethod="GetPageData"是取得分頁信息
而EnablePaging="true"
**先按正常流程配置ListView的objectDataSource,讓ListVIew自動生成
再去配置分頁數(shù)據(jù)源

相關(guān)文章

最新評論