Need to make a line in normal mode after updating

I have a gridview with the "Edit Update Cancel" field. When I click "Edit", all the columns in a particular row become editable, and when I click "Refresh", the table is updated based on the new values. Gridview then binds to the updated datatable. But the "Cancel update" button still remains.

alt text

After the line has been updated, the "Undo Update" button should be changed to "Edit." How it became possible.

Thanks at Advance

This is the code for updating and displaying 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 = 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
            }
        }
+5
source share
1

GridView1.EditIndex = -1 this.StaticNoticeGridView.DataBind(); StaticNoticeGridView_RowUpdating

+11

All Articles