您的位置:首页 > 其它

GridView 控件事件发生顺序

2008-04-21 17:52 281 查看
一、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

总结:

在 GridView 绑定数据开始,也就是触发 DataBounding 事件后,这时已经把数据从数据源取出或者说已经规定了那些数据字段将会被取出,其中 的 Visible 属性为 false 的字段的值是不会从数据源中获取的。这就是为什么当 GridView 使用直接在 html 中将 Visible=false 来隐藏某一列时,会得不到该列的值。然后调用 RowCreated 事件把一行数据全部填充到一个 gridViewRow 里面,然后触发 RowDataBound 事件把该行绑定到 GridView 的 Rows 中。一直到最后触发 GridView 的 DataBound 来绑定显示数据。
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: