Ana*_*nth 5 .net c# asp.net gridview
我有一个带有"编辑更新取消"命令字段的gridview.单击"编辑"时,特定行中的所有列都将变为可编辑状态,当我单击"更新"时,将根据新值更新表.然后Gridview与更新的数据表绑定.但"更新取消"按钮仍然存在.

一旦更新了行,"更新取消"按钮必须更改为"编辑",那么这是如何实现的.
提前致谢
这是用于更新和显示更新数据的代码
protected void StaticNoticeGridView_RowUpdating(object sender, GridViewUpdateEventArgs e)
{
try
{
//Gets the updated value from GridView
string id = StaticNoticeGridView.Rows[e.RowIndex].Cells[0].Text;
string updatedItem = e.NewValues[0].ToString();
string updatedURL = e.NewValues[1].ToString();
//Updated the Database
StaticNoticeController staticNoticeController = new StaticNoticeController();
int rocordsAffected = staticNoticeController.UpdateStaticNoticeData(updatedItem, updatedURL, id);
//Gets the updated datatable and binds the Gridview again
if (rocordsAffected == 1)
{
this.StaticNoticeGridView.DataSource = null;
this.StaticNoticeGridView.DataSource = staticNoticeController.GetStaticNoticeData();
this.StaticNoticeGridView.DataBind();
}
}
catch(SystemException ex)
{
//ToDo: Log the Exception
}
}
Run Code Online (Sandbox Code Playgroud)
Vij*_*iri 11
this.StaticNoticeGridView.DataBind();在方法之前设置GridView1.EditIndex = -1;StaticNoticeGridView_RowUpdating