Gridview行绑定事件新体会
2010-04-22 09:43
309 查看
最近在做统计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中的事件中去处理。
来源:http://www.cnblogs.com/hovering/archive/2009/11/29/1613365.html
事件执行顺序:
一、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中的事件中去处理。
来源:http://www.cnblogs.com/hovering/archive/2009/11/29/1613365.html
相关文章推荐
- asp.net Gridview行绑定事件新体会
- asp gridview 事件绑定
- GridView 操作事件绑定技巧,单元格属性绑定指定值
- asp.net customdatagrid 或gridview绑定数据的时候经常要用到的 ItemDataBound 事件的方法
- GridView的DataSource绑定DataSet后,PageIndexChanging事件
- 在GridView_RowDataBound事件中绑定列
- GridView的技巧 绑定行事件,取得单元格值,或取得单元格控件方法,鼠标经过样式
- GridView动态添加模板列(并为其添加事件和自动绑定数据)
- GridView绑定时通过RowDataBound事件获取数据源列值
- 行绑定事件 protected void js_list_RowDataBound(object sender, System.Web.UI.WebControls.GridViewRowEventArgs e)
- GridView 行单击或双击事件绑定
- GridView绑定事件
- datalist、repeater、gridview中绑定事件中行判断
- GridView控件常见问题及处理方法===1. 关于隐藏字段的处理:==2. 关于按钮列的事件:==3. 关于按钮的客户端提示:==4. 关于时间字段的格式化输出:==5. 关于绑定空记录:
- 菜鸟学Asp.Net——GridView控件之RowDataBind事件中如何获取已绑定的数据
- GridView绑定时通过RowDataBound事件获取数据源列值
- GridView变形,发生在重新绑定或者执行update、command等事件后
- GridView绑定时通过RowDataBound事件获取数据源列值
- 在gridview的RowDeleting事件中获得gridview绑定的主键
- GridView 动态绑定控件 OnRowCommand事件触发