在asp.net Gridview控件中触发事件的顺序是什么? [英] What is the sequence of events firing off in asp.net Gridview control?

查看:113
本文介绍了在asp.net Gridview控件中触发事件的顺序是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我经常使用GridViews,有时我会对某些代码的放置位置感到困惑。事件发生的顺序是什么,包括所有页面事件?

编辑:
我也在试着理解页面和Gridview之间会发生什么。这些事件是否会交叉?或者所有页面事件一次发生,那么所有的Gridview事件都会发生?不仅仅是GridViews,任何控件 - 但大多是页面和GridView的交互。

解决方案

  protected void GridView1_Load(object sender,EventArgs e)
{
System.Diagnostics.Debug.WriteLine(GridView1_Load);

protected void GridView1_DataBinding(object sender,EventArgs e)
{
System.Diagnostics.Debug.WriteLine(GridView1_DataBinding);

protected void GridView1_DataBound(object sender,EventArgs e)
{
System.Diagnostics.Debug.WriteLine(GridView1_DataBound);

protected void GridView1_RowDataBound(object sender,GridViewRowEventArgs e)
{
System.Diagnostics.Debug.WriteLine(GridView1_RowDataBound);
}


I use GridViews pretty often and sometimes I get confused to where to put certain code. What is the sequence that events are fired off including all page events?

Edited: I really am also trying to understand what happens between the page and the Gridview. Do the events ever cross? Or do all page events occur at once then all Gridview events occur? And not just GridViews, any control - but mostly page and GridView interaction.

解决方案

protected void GridView1_Load(object sender, EventArgs e)
{
   System.Diagnostics.Debug.WriteLine("GridView1_Load");
}
protected void GridView1_DataBinding(object sender, EventArgs e)
{
   System.Diagnostics.Debug.WriteLine("GridView1_DataBinding");
}
protected void GridView1_DataBound(object sender, EventArgs e)
{
   System.Diagnostics.Debug.WriteLine("GridView1_DataBound");
}
protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
{
   System.Diagnostics.Debug.WriteLine("GridView1_RowDataBound");
}

这篇关于在asp.net Gridview控件中触发事件的顺序是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆