GridView的RowCreated与RowDataBound事件区别
在西门子面试时,项目负责人除了道试题关于RowCreated与RowDataBound事件区别,经过google一下,得出结果:
GridView的RowCreated与RowDataBound的一个区别在于RowCreated事件是这样的,不管数据是不是重新绑定到GridView,只要在GridView里新增一行记录就将引发RowCreated事件。那意味着,当发生PostBack回传事件时,哪怕数据来自视图状态,也会引发RowCreated事件。
我们使用RowCreated事件而不使用RowDataBound事件的原因在于,只有当数据明确的绑定到数据Web控件时才会引发RowDataBound事件.
RowDataBound是数据绑定的时候才会触发,RowCreated是每次呈现的时候都要触发,RowCreated先于RowDataBound执行。
举个列,如果页面回发后发生过GridView.databind(),那么两个事件都会触发。如果没发生GridView.databind(),那么就只会触发RowCreated。
事件执行顺序:
一、GridView 显示绑定的数据顺序如下:
DataBinding ->RowCreated ->RowDataBound ->...... ->DataBound
二、GridView 点击分页按钮时的事件发生顺序:
RowCommand >PageIndexChanging >PageIndexChanged >DataBinding >RowCreated:Header>RowDataBound > RowCreated:DataRow >RowDataBound >RowCreated:Footer>RowDataBound >RowCreated:Pager >RowDataBound>
DataBound
理解也就是在点跳页按钮的时候,只会绑定要显示的页的资料,如上,因此在RowDataBound中不会绑定所有的资料,此时去统计,只能统计出当前页的加总。
目前想来,也只有对要绑定的资料进行统计了。不能在GridView中的事件中去处理。
GridView的RowCreated与RowDataBound事件区别的更多相关文章
- GridView的 PreRender事件与 RowCreated、RowDataBound事件大乱斗
GridView的 PreRender事件与 RowCreated.RowDataBound事件大乱斗 之前写了几个范例,做了GridView的 PreRender事件与 RowCreated.Row ...
- GridView控件RowDataBound事件中获取列字段值的几种途径 !!!
protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e) { if (e.Row.RowType == ...
- GridView控件RowDataBound事件中获取列字段值的几种途径
前台: <asp:TemplateField HeaderText="充值总额|账号余额"> <ItemTemplate> <asp:Label ID ...
- RowDataBound事件
RowDataBound事件在创建gridView控件时,必须先为GridView的每一行创建一个GridViewRow对象,创建每一行时,将引发一个RowCreated事件:当行创建完毕,每一行Gr ...
- js onkeypress与onkeydown 事件区别详细说明
keypress只适用于有字符输入的按键 而keyup/keydown包含了Ctrl, Shift之类的情况 Firefox在处理onKeyDown/onKeyPress事件时存在漏洞,恶意网页可能利 ...
- GridView点击空白地方事件扩展
我们通常在ListView或者GridView响应点击Item事件,但很多时候我们同样也 希望监听到点击空白区域的事件来做更多的处理.本文以GridView为例给出一个实现 的方法,扩展GridVie ...
- Gridview的RowDataBound事件(添加删除提示,改变背景颜色)
protected void gvTest_RowDataBound(object sender, GridViewRowEventArgs e) { //如果是绑定数据行 if (e.Row.Row ...
- Gridview的RowDataBound事件可以做很多事情
protected void gvTest_RowDataBound(object sender, GridViewRowEventArgs e) { //如果是绑 ...
- GridView控件RowDataBound事件中获取列字段途径
今天不知道怎么回事怎么也找不到gridview列中的控件,关键是其为编辑时隐藏域中的控件,取值就很成问题了,网上搜了很到,找到这个比较经典的东东了,可能大家都知道,但很少对比整理到一起,有多种方法可以 ...
随机推荐
- IIS6 伪静态
1. 设置IIS--主目录--脚本映射那一个属性 2.必须还要上传自己的urlrewriter组件,并在config里做相应的设置 二者缺一不可
- linux文件特殊属性介绍(s,s,t)
文件的权限有rwx这3个读.写.执行的权限.但是,怎么 /tmp权限有些奇怪?还有, /usr/bin/passwd也有些奇怪,怎么回事呢? [root@linux ~]# ls -ld /tmp ; ...
- LeetCode OJ 107. Binary Tree Level Order Traversal II
Given a binary tree, return the bottom-up level order traversal of its nodes' values. (ie, from left ...
- PHP:preg_replace
关于preg_match: http://www.cnblogs.com/helww/p/3466720.html 关于preg_match_all:暂时没有完整的 preg_replace_call ...
- login/logout切换
1. 前端按钮 <img border="0" width="18" height="18" src="<%=base ...
- Asp.Net调用Office组件操作时的DCOM配置 (转)
Asp.Net调用Office组件操作时的DCOM配置 http://blog.csdn.net/gz775/article/details/6447758 在项目中将数据导出为Excel格式时出现“ ...
- DotNetBar教程
DotNetBar是一组用于.NET Framework环境下的一组组件集,利用该组件集能够打造绚丽并且实用的应用程序界面,给开发人员提供极大的便利.关于DotNetBar,详情请参考其官方网站:ht ...
- lepus bug
------------------------------------------------BUG fix-------------------------------------------- ...
- CSS单行、多行文本溢出显示省略号(……)
这个问题经常遇到 1.单行文本溢出显示省略号(…) text-overflow:ellipsis-----部分浏览器还需要加宽度width属性 overflow:hidden;text-overflo ...
- TcpClient 读写流
TcpClient 读写流 TcpClient tcp = new TcpClient(); tcp.Connect(IPAddress.Parse("192.168.1.161" ...