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

asp.net Gridview行綁定事件新體會

 更新時間:2009年11月30日 20:50:25   作者:  
最近在做統(tǒng)計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] //不管有沒有頁角行,該事件都會發(fā)生
RowDataBound
RowCreated:Pager[7]
RowDataBound
DataBound

順序如下:

DataBinding
RowCreated
RowDataBound
......
DataBound

二、GridView 點擊分頁按鈕時的事件發(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

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

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

相關(guān)文章

最新評論