GridView事件标注

DataBinding 当服务器控件绑定到数据源时发生。 (从 Control 继承。)  
DataBound 在服务器控件绑定到数据源后发生。 (从 BaseDataBoundControl 继承。)  
Disposed 当从内存释放服务器控件时发生,这是请求 ASP.NET 页时服务器控件生存期的最后阶段。 (从 Control 继承。)  
Init 当服务器控件初始化时发生;初始化是控件生存期的第一步。 (从 Control 继承。)  
Load 当服务器控件加载到 Page 对象中时发生。 (从 Control 继承。)  
PageIndexChanged 在单击某一页导航按钮时,但在 GridView 控件处理分页操作之后发生。  
PageIndexChanging 在单击某一页导航按钮时,但在 GridView 控件处理分页操作之前发生。  
PreRender 在加载 Control 对象之后、呈现之前发生。 (从 Control 继承。)  
RowCancelingEdit 单击编辑模式中某一行的“取消”按钮以后,在该行退出编辑模式之前发生。  
RowCommand 当单击 GridView 控件中的按钮时发生。  
RowCreated 在 GridView 控件中创建行时发生。  
RowDataBound 在 GridView 控件中将数据行绑定到数据时发生。  
RowDeleted 在单击某一行的“删除”按钮时,但在 GridView 控件删除该行之后发生。  
RowDeleting 在单击某一行的“删除”按钮时,但在 GridView 控件删除该行之前发生。  
RowEditing 发生在单击某一行的“编辑”按钮以后,GridView 控件进入编辑模式之前。  
RowUpdated 发生在单击某一行的“更新”按钮,并且 GridView 控件对该行进行更新之后。  
RowUpdating 发生在单击某一行的“更新”按钮以后,GridView 控件对该行进行更新之前。  
SelectedIndexChanged 发生在单击某一行的“选择”按钮,GridView 控件对相应的选择操作进行处理之后。  
SelectedIndexChanging 发生在单击某一行的“选择”按钮以后,GridView 控件对相应的选择操作进行处理之前。  
Sorted 在单击用于列排序的超链接时,但在 GridView 控件对相应的排序操作进行处理之后发生。  
Sorting 在单击用于列排序的超链接时,但在 GridView 控件对相应的排序操作进行处理之前发生。  
Unload 当服务器控件从内存中卸载时发生。 (从 Control 继承。)  

一、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

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章