日期:2014-05-20  浏览次数:20405 次

vs.net2005中的GridView的事件问题
1、RowDataBound事件中用
  if(e.Row.RowType       ==       DataControlRowType.DataRow)      
                    {      
                          string   lblDatatype   =   ((Label)e.Row.FindControl( "lblDataType ")).Text;
                    }
如果这个控件是放在模板列的编辑列 <ItemTemplate> </ItemTemplate> 中
则编辑某一列时会出错。怎么判断在某行是在编辑状态的,不执行FindControl?
2、为什么取消编辑时,一定要定义RowCancelingEdit事件,即使我并不需要在那里写任何代码(我可以在RowCommand事件里写取消编辑该行)?

------解决方案--------------------
if(e.Row.RowIndex == this.GridView1.EditIndex)
------解决方案--------------------
顶一楼
------解决方案--------------------
protected void GridViewList_RowEditing(object sender, GridViewEditEventArgs e)
{
GridViewList.EditIndex = e.NewEditIndex;
...
}