GridView事件DataBinding,DataBound,RowCreated,RowDataBound区别及执行顺序分析
严格的说,DataBinding,DataBound并不是GridView特有的事件,其他的控件诸如ListBox等也有DataBinding,DataBound事件。
DataBinding事件
MSDN解释:Occurs when the server control binds to a data source.
This event notifies the server control to perform any data-binding logic that has been written for it.
译为:该事件当服务器控件绑定数据时发生。
DataBound事件
MSDN解释:Occurs after the server control binds to a data source.
This event notifies the server control that any data binding logic written for it has completed.
译为:该事件当服务器控件完成数据绑定后发生。
RowCreated事件
MSDN解释:Occurs when a row is created in a GridView control.
译为:当GridView的行被创建时发生。
RowDataBound事件
MSDN解释:Occurs when a data row is bound to data in a GridView control.
译为:当GridView的行被绑定数据时发生。
四个事件的执行顺序:
假定GridView有3行数据
aspx代码
- <asp:GridView
- ID="GridViewMain"
- runat="server"
- AutoGenerateColumns="False"
- OnDataBinding="GridViewMain_DataBinding"
- OnDataBound="GridViewMain_DataBound"
- OnRowCreated="GridViewMain_RowCreated"
- OnRowDataBound="GridViewMain_RowDataBound"
- >
cs代码(只含事件头)
- protected void GridViewMain_DataBinding(object sender,EventArgs e)
- {
- }
- protected void GridViewMain_DataBound
- (object sender,EventArgs e)
- {
- }
- protected void GridViewMain_RowCreated(object sender, GridViewRowEventArgs e)
- {
- }
- protected void GridViewMain_RowDataBound(object sender, GridViewRowEventArgs e)
- {
- }
发生次序是:
1. DataBinding
2. RowCreated
3. RowDataBound
4. RowCreated
5. RowDataBound
6. RowCreated
7. RowDataBound
8. DataBound
GridView取得数据有3条,因此Row的相关事件执行3次。
另外,从字面本身也可知事件之间的区别
比如,DataBound,DataBinding两个事件,单词Bound是Bind的过去式,即DataBound是绑定事件完成后发生的。
还有诸如RowDeleted,RowDeleting,都可以从词义本身的差别加以区分。
GridView事件DataBinding,DataBound,RowCreated,RowDataBound区别及执行顺序分析的更多相关文章
- 简单理解Struts2中拦截器与过滤器的区别及执行顺序
简单理解Struts2中拦截器与过滤器的区别及执行顺序 当接收到一个httprequest , a) 当外部的httpservletrequest到来时 b) 初始到了servlet容器 传递给一个标 ...
- JQ中$(window).load和$(document).ready区别与执行顺序
JQ中的$(document).ready()大家应该用的非常多,等同于$(function(){}),基本每个JS脚本中都有这个函数的出现有时甚至会出现多个,那么另一个加载函数$(window).l ...
- [转]JQ中$(window).load和$(document).ready区别与执行顺序
一.$(window).load().window.onload=function(){}和$(document).ready()方法的区别 1.$(window).load() 和window.on ...
- Spring filter和拦截器(Interceptor)的区别和执行顺序
转载自:http://listenup.iteye.com/blog/1559553 1.Filter过滤器只过滤jsp文件不过滤action请求解决方案 解决办法:在web.xml中将filter的 ...
- JavaWeb-拦截器,过滤器,监听器的区别和执行顺序
一:拦截器 :是在面向切面编程的就是在你的service或者一个方法,前调用一个方法,或者在方法后调用一个方法比如动态代理就是拦截器的简单实现,springmvc的aop中的前置通知和后置通知. 二: ...
- 转: Struts2中拦截器与过滤器的区别及执行顺序
当接收到一个httprequest , a) 当外部的httpservletrequest到来时 b) 初始到了servlet容器 传递给一个标准的过滤器链 c) FilterDispatecher会 ...
- asp.net学习之GridView事件、GridViewRow对象
原文:asp.net学习之GridView事件.GridViewRow对象 1. GridView控件的事件 GridView有很多事件,事件可以定制控件的外观或者行为.事件分为三类 1.1 ...
- GridView事件分析
GridView事件分析 (转) P1默认数据绑定过程 编号 事件名称 作用 E1 DataBinding 数据绑定之前触发,在这个事件之前(第一次生成GridView),GridView不存在行数据 ...
- 微信小程序 事件绑定 bind和catch 区别
转自:https://blog.csdn.net/xiaoqiang_0719/article/details/79729592 本文以冒泡事件tap(手指触摸后马上离开,也就是点击事件)为例子来区别 ...
随机推荐
- iOS 面试题汇总
1. Object-c的类可以多重继承么?可以实现多个接口么?Category是什么?重写一个类的方式用继承好还是分类好?为什么? 答: Object-c的类不可以多重继承;可以实现多个接口,通过实现 ...
- Qwt 折线图 波形图 柱状图示例效果
Qwt 目录下有不少 example,为了快速找到想要研究使用的例子,特意把所有例子的示例效果截图下来窗口标题即是 example 下的目录名称
- Python初学
经同学推荐,学习了下Python语言,看Python的介绍,它本身是一个面向对象的解释型脚本语言,我初看到这句话的时候就在想,一个脚本语言还搞成面向对象?有这个必要么?原谅我肤浅了一把. 它还被俗称为 ...
- 如何系统地学习JavaScript
在过去,JavaScript只是被用来做一些简单的网页效果,比如表单验证.浮动广告等,所以那时候JavaScript并没有受到重视.自从AJAX开始流行后,人们发现利用JavaScript可以给用户带 ...
- 谈谈自己对于Auth2.0的见解
Auth的原理网上有很多,我这里就不在赘述了. 这里有张时序图我个人觉得是比较合理而且直观的,(感谢这篇博文:http://justcoding.iteye.com/blog/1950270) 参照这 ...
- firefox因gnash cpu 高
sudo apt-get remove --purge gnash 去adobe下载adobe flash for linux 解压 tar zxvf install_flash_player_11_ ...
- C# 父子类_实例_静态成员变量_构造函数的执行顺序
今天去面试的时候被一道题问得一点脾气都没有,今天特地来研究下. 子类成员变量,子类静态成员变量,子类构造函数,父类成员变量,父类静态成员变量,父类构造函数的执行顺序. 现在贴上从另外一个.net程序员 ...
- 在javascript中使用com组件的方法
转载自: http://dhailin.blog.163.com/blog/static/230738322011128102043880/ 首先创建一个COM组件,插入一个双接口Itest,在此接 ...
- poj 1001 求高精度幂
本题的测试用例十分刁钻,必须要考虑到很多的细节问题,在这里给出一组测试用例及运行结果: 95.123 12 548815620517731830194541.899025343415715973535 ...
- LeeCode(Database)-Combine Two Tables
Table: Person +-------------+---------+ | Column Name | Type | +-------------+---------+ | PersonId ...