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行):
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ā)生順序:
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中的事件中去處理。
事件執(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)文章
ASP.NET MVC5網(wǎng)站開發(fā)修改及刪除文章(十)
這篇文章主要為大家詳細(xì)介紹了ASP.NET MVC5網(wǎng)站開發(fā)修改及刪除文章,文中示例代碼介紹的非常詳細(xì),具有一定的參考價值,感興趣的小伙伴們可以參考一下2015-09-09
關(guān)于DDD:管理"工作單元實例"的兩種模式的使用方法
本篇文章介紹了,關(guān)于DDD:管理"工作單元實例"的兩種模式的使用方法。需要的朋友參考下2013-04-04
ASP.NET MVC使用ActionFilterAttribute實現(xiàn)權(quán)限限制的方法(附demo源碼下載)
這篇文章主要介紹了ASP.NET MVC使用ActionFilterAttribute實現(xiàn)權(quán)限限制的方法,結(jié)合實例形式分析了ASP.NET MVC使用ActionFilterAttribute過濾類實現(xiàn)權(quán)限限制的步驟與相關(guān)技巧,并附帶demo源碼供讀者下載,需要的朋友可以參考下2016-04-04
.NET?API?接口數(shù)據(jù)傳輸加密最佳實踐記錄
這篇文章主要介紹了.NET?API?接口數(shù)據(jù)傳輸加密最佳實踐記錄,我們在做?Api?接口時,相信一定會有接觸到要給傳輸?shù)恼埱?body?的內(nèi)容進(jìn)行加密傳輸。其目的就是為了防止一些敏感的內(nèi)容直接被?UI?層查看或篡改,需要的朋友可以參考下2022-10-10
ASP.NET Core應(yīng)用錯誤處理之三種呈現(xiàn)錯誤頁面的方式
這篇文章主要給大家介紹了關(guān)于ASP.NET Core應(yīng)用錯誤處理之三種呈現(xiàn)錯誤頁面的方式的相關(guān)資料,文中通過示例代碼介紹的非常詳細(xì),對大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧2019-01-01
Asp.net XMLHTTP封裝類(GET,Post發(fā)送和接收數(shù)據(jù))
XMLHTTP封裝類可以向遠(yuǎn)程發(fā)送URL和參數(shù),接受返回信息(無亂碼)2008-11-11

