GridView 绑定问题 在线等!
我用2个GridView控件 分别绑定2个数据源 一个是sqldatasource 一个是objectdatasource 分别绑定
绑定以后 在2个GridView 分别加了2个按钮 一个是编辑一个是取消 (当然commandName 是edit,cancle )
现在出现的问题就是 和sqldatasource 数据源绑定的Grid 在点击编辑和取消时候没有问题
但是和objectdatasource 数据源绑定的Grid 需要点击2次才能触发编辑或者取消事件。
后台代码也不太相同
1绑定sqldatasource :
protected void GridView1_RowCancelingEdit(object sender, GridViewCancelEditEventArgs e)
{
this.GridView1.EditIndex = -1;
}
只需要写取消的代码,编辑的代码不用写;点击操作只需要1次。(正常)
2绑定objectdatasource:
protected void GridView2_RowCancelingEdit(object sender, GridViewCancelEditEventArgs e)
{
this.GridView2.EditIndex = -1;
}
protected void GridView2_RowEditing(object sender, GridViewEditEventArgs e)
{
this.GridView2.EditIndex = e.NewEditIndex;
}
编辑和取消的代码都要写,而且效果是要操作2次才可以。(不正常)