亚洲乱码中文字幕综合,中国熟女仑乱hd,亚洲精品乱拍国产一区二区三区,一本大道卡一卡二卡三乱码全集资源,又粗又黄又硬又爽的免费视频

asp.net Gridview行綁定事件新體會(huì)

 更新時(shí)間:2009年11月30日 20:50:25   作者:  
最近在做統(tǒng)計(jì)GridView中某一列的加總值,之前有在RowDataBound事件中中逐筆加總,經(jīng)過測試才知道,這是不正確的,并不能得到所有資料的加總值。
在網(wǎng)上搜了一下事件執(zhí)行順序,并經(jīng)過測試在有分頁的情況下是不正確的。
事件執(zhí)行順序:

一、GridView 顯示綁定的數(shù)據(jù)(默認(rèn)為5行):
復(fù)制代碼 代碼如下:

DataBinding
RowCreated:Header[0]
RowDataBound
RowCreated:DataRow[1]
RowDataBound
RowCreated:DataRow[2]
RowDataBound
RowCreated:DataRow[3]
RowDataBound
RowCreated:DataRow[4]
RowDataBound
RowCreated:DataRow[5]
RowDataBound
RowCreated:Footer[6] //不管有沒有頁角行,該事件都會(huì)發(fā)生
RowDataBound
RowCreated:Pager[7]
RowDataBound
DataBound

順序如下:

DataBinding
RowCreated
RowDataBound
......
DataBound

二、GridView 點(diǎn)擊分頁按鈕時(shí)的事件發(fā)生順序:
復(fù)制代碼 代碼如下:

RowCommand
PageIndexChanging
PageIndexChanged
DataBinding
RowCreated:Header[8]
RowDataBound
RowCreated:DataRow[9]
RowDataBound
RowCreated:DataRow[10]
RowDataBound
RowCreated:DataRow[11]
RowDataBound
RowCreated:DataRow[12]
RowDataBound
RowCreated:DataRow[13]
RowDataBound
RowCreated:Footer[14]
RowDataBound
RowCreated:Pager[15]
RowDataBound
DataBound

理解也就是在點(diǎn)跳頁按鈕的時(shí)候,只會(huì)綁定要顯示的頁的資料,如上,因此在RowDataBound中不會(huì)綁定所有的資料,此時(shí)去統(tǒng)計(jì),只能統(tǒng)計(jì)出當(dāng)前頁的加總(如上9-13筆的資料)

目前想來,也只有對要綁定的資料進(jìn)行統(tǒng)計(jì)了。不能在GridView中的事件中去處理。

相關(guān)文章

最新評論