编辑索引更改时绑定数据 [英] binding data when edit index is changed
问题描述
我正在使用gridview,我正在使用编辑按钮更新数据。
更新完成后我将网格重新放入编辑模式,但我需要在更新后绑定数据,所以问题是,当我在更新事件中使用此命令时:
GridView1.EditIndex = -1
网格不再处于更新模式,也不处于编辑模式,因此使用此命令将用于绑定数据的事件是什么:
GridView1.DataBind()
如果我在更改索引之前放入数据绑定,editIndex将不会更改..
非常感谢任何帮助!
谢谢..
如果您想在更新行后触发RowEditing
,请在RowUpdating $中执行以下操作c $ c>活动。
<前lang =cs> 受保护 void GridView1_RowUpdating( object sender,GridViewUpdateEventArgs e)
{
// ......其他代码........... //
GridView1.EditIndex = -1;
// 更新后绑定GridView。
GridView1。的DataBind();
// 现在调用RowEditing事件。
GridView1_RowEditing( sender, new GridViewEditEventArgs(e.RowIndex));
}
I'm using a gridview and I'm updating the data using the edit button.
when the update is completed I'm putting the grid back to the edit mode but i need to bind the data after the update so the problem is that when i use this command in the updating event:
GridView1.EditIndex = -1
the grid is not in the updating mode anymore nor in the editing mode so what is the event that i should use to bind the data using this command:
GridView1.DataBind()
and if i put the databind before changing the index, the editIndex will not change..
any help is much appreciated !
thank you..
If you want to fireRowEditing
after updating the row, then do like below inRowUpdating
Event.
protected void GridView1_RowUpdating(object sender, GridViewUpdateEventArgs e) { //...... Other codes...........// GridView1.EditIndex = -1; // Binding the GridView after update. GridView1.DataBind(); // Now call the RowEditing Event. GridView1_RowEditing(sender, new GridViewEditEventArgs(e.RowIndex)); }
这篇关于编辑索引更改时绑定数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!