asp.net Gridview行绑定事件新体会
更新时间:2009年11月30日 20:50:25 作者:
最近在做统计GridView中某一列的加总值,之前有在RowDataBound事件中中逐笔加总,经过测试才知道,这是不正确的,并不能得到所有资料的加总值。
在网上搜了一下事件执行顺序,并经过测试在有分页的情况下是不正确的。
事件执行顺序:
一、GridView 显示绑定的数据(默认为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] //不管有没有页角行,该事件都会发生
RowDataBound
RowCreated:Pager[7]
RowDataBound
DataBound
顺序如下:
DataBinding
RowCreated
RowDataBound
......
DataBound
二、GridView 点击分页按钮时的事件发生顺序:
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中不会绑定所有的资料,此时去统计,只能统计出当前页的加总(如上9-13笔的资料)
目前想来,也只有对要绑定的资料进行统计了。不能在GridView中的事件中去处理。
事件执行顺序:
一、GridView 显示绑定的数据(默认为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] //不管有没有页角行,该事件都会发生
RowDataBound
RowCreated:Pager[7]
RowDataBound
DataBound
顺序如下:
DataBinding
RowCreated
RowDataBound
......
DataBound
二、GridView 点击分页按钮时的事件发生顺序:
复制代码 代码如下:
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中不会绑定所有的资料,此时去统计,只能统计出当前页的加总(如上9-13笔的资料)
目前想来,也只有对要绑定的资料进行统计了。不能在GridView中的事件中去处理。
您可能感兴趣的文章:
相关文章
ASP.NET MVC使用ActionFilterAttribute实现权限限制的方法(附demo源码下载)
这篇文章主要介绍了ASP.NET MVC使用ActionFilterAttribute实现权限限制的方法,结合实例形式分析了ASP.NET MVC使用ActionFilterAttribute过滤类实现权限限制的步骤与相关技巧,并附带demo源码供读者下载,需要的朋友可以参考下2016-04-04ASP.NET Core应用错误处理之三种呈现错误页面的方式
这篇文章主要给大家介绍了关于ASP.NET Core应用错误处理之三种呈现错误页面的方式的相关资料,文中通过示例代码介绍的非常详细,对大家的学习或者工作具有一定的参考学习价值,需要的朋友们下面随着小编来一起学习学习吧2019-01-01Asp.net XMLHTTP封装类(GET,Post发送和接收数据)
XMLHTTP封装类可以向远程发送URL和参数,接受返回信息(无乱码)2008-11-11
最新评论