严格的说,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代码

  1. <asp:GridView
  2. ID="GridViewMain"
  3. runat="server"
  4. AutoGenerateColumns="False"
  5. OnDataBinding="GridViewMain_DataBinding"
  6. OnDataBound="GridViewMain_DataBound"
  7. OnRowCreated="GridViewMain_RowCreated"
  8. OnRowDataBound="GridViewMain_RowDataBound"
  9. >

cs代码(只含事件头)

  1. protected void GridViewMain_DataBinding(object sender,EventArgs e)
  2. {
  3. }
  4. protected void GridViewMain_DataBound
  5. (object sender,EventArgs e)
  6. {
  7. }
  8. protected void GridViewMain_RowCreated(object sender, GridViewRowEventArgs e)
  9. {
  10. }
  11. protected void GridViewMain_RowDataBound(object sender, GridViewRowEventArgs e)
  12. {
  13. }

发生次序是:
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区别及执行顺序分析的更多相关文章

  1. 简单理解Struts2中拦截器与过滤器的区别及执行顺序

    简单理解Struts2中拦截器与过滤器的区别及执行顺序 当接收到一个httprequest , a) 当外部的httpservletrequest到来时 b) 初始到了servlet容器 传递给一个标 ...

  2. JQ中$(window).load和$(document).ready区别与执行顺序

    JQ中的$(document).ready()大家应该用的非常多,等同于$(function(){}),基本每个JS脚本中都有这个函数的出现有时甚至会出现多个,那么另一个加载函数$(window).l ...

  3. [转]JQ中$(window).load和$(document).ready区别与执行顺序

    一.$(window).load().window.onload=function(){}和$(document).ready()方法的区别 1.$(window).load() 和window.on ...

  4. Spring filter和拦截器(Interceptor)的区别和执行顺序

    转载自:http://listenup.iteye.com/blog/1559553 1.Filter过滤器只过滤jsp文件不过滤action请求解决方案 解决办法:在web.xml中将filter的 ...

  5. JavaWeb-拦截器,过滤器,监听器的区别和执行顺序

    一:拦截器 :是在面向切面编程的就是在你的service或者一个方法,前调用一个方法,或者在方法后调用一个方法比如动态代理就是拦截器的简单实现,springmvc的aop中的前置通知和后置通知. 二: ...

  6. 转: Struts2中拦截器与过滤器的区别及执行顺序

    当接收到一个httprequest , a) 当外部的httpservletrequest到来时 b) 初始到了servlet容器 传递给一个标准的过滤器链 c) FilterDispatecher会 ...

  7. asp.net学习之GridView事件、GridViewRow对象

    原文:asp.net学习之GridView事件.GridViewRow对象 1. GridView控件的事件 GridView有很多事件,事件可以定制控件的外观或者行为.事件分为三类     1.1 ...

  8. GridView事件分析

    GridView事件分析 (转) P1默认数据绑定过程 编号 事件名称 作用 E1 DataBinding 数据绑定之前触发,在这个事件之前(第一次生成GridView),GridView不存在行数据 ...

  9. 微信小程序 事件绑定 bind和catch 区别

    转自:https://blog.csdn.net/xiaoqiang_0719/article/details/79729592 本文以冒泡事件tap(手指触摸后马上离开,也就是点击事件)为例子来区别 ...

随机推荐

  1. [canvas]通过动态生成像素点做绚丽效果

    本例中的粒子就是实实在在的像素,由js代码在canvas上动态生成的像素点!这些像素点通过一个运动方法有规律地动了起来.透过这个思路,我们可以想到很多很炫的效果,但是这个性能有待考察.实验证明,动态控 ...

  2. asp.net缓存(三)

    Asp.net应用程序数据缓存 System.Web.Caching 命名空间提供用于缓存服务器上常用数据的类.此命名空间包括 Cache 类,该类是一个字典,您可以在其中存储任意数据对象,如哈希表和 ...

  3. css链接,列表,表格

    1.css链接 a:link - 正常,未访问过的链接 a:visited - 用户已访问过的链接 a:hover - 当用户鼠标放在链接上时 a:active - 链接被点击的那一刻 注意: a:h ...

  4. codeforces 335A Banana(贪心)

    转载请注明出处: http://www.cnblogs.com/fraud/          ——by fraud    Banana Piegirl is buying stickers for ...

  5. kinect

    1.学习资料 http://blog.csdn.net/dustpg/article/details/37982311 https://github.com/mdkus/kinect-mssdk-op ...

  6. 当nginx 500 伪静态错误时,记录解决方法rewrite or internal redirection cycle while processing

    错误日志::rewrite or internal redirection cycle while processing "/index.php/index.php/index.php/in ...

  7. 解决: AGPBI: {"kind":"error","text":"indicate that it is *not* an inner class.","sources":[{}]}

    关于Gradle Console输出类似这样错误信息: AGPBI: {"kind":"error","text":"indica ...

  8. ZendFramework2 源码分析 init_autoloader.php

    // Composer autoloading if (file_exists('vendor/autoload.php')) { // 加载自动加载器 $loader = include 'vend ...

  9. wifi智能插座 一键扫描局域网内插座Ip及其它信息 Python源代码API

    转载请保留原地址. http://www.cnblogs.com/lsqandzy 最近买了几个智能插座玩,插座安装在家里,连接好wifi,不管你人在哪里,通过手机,一键开启或关闭插座电源,想象一下, ...

  10. 从客户端(******)中检测到有潜在危险的 Request.Form 值。

    在 提交表单时候,asp.net 提示:"从客户端(......)中检测到有潜在危险的 Request.Form 值" .asp.net中的请求验证特性提供了某一等级的保护措施防止 ...