Need to make the row in normal mode after updating
I have a gridview with "Edit Update Cancel" command field. When I click Edit, all the columns in the particular row becomes editable and when I click update, the Table is updated based on the new values. Then the Gridview is binded with the updated datatable. But the "Update Cancel" button still remains.
Once the row , has been updated, the "Update Cancel" button has to be changed to "Edit" So how is that made possible.
Thanks in Advance
This is the code for updating and displaying the updated data
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 = staticNo开发者_开发知识库ticeController.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
}
}
set GridView1.EditIndex = -1;before this.StaticNoticeGridView.DataBind();
in the method StaticNoticeGridView_RowUpdating
精彩评论