You didn't ask this in your question, but you've written some smelly code here.
I'll try to address your question, but I'm also going through some of the other problems here.
You can also indicate whether the exception was handled in the event-handling method by setting the On Row Updated Row Canceling Edit On Row Canceling Edit Row Deleted On Row Deleted Row Deleting On Row Deleting Row Editing On Row Editing Row Updating On Row Updating Grid View Class System.
Save all or press "Ctrl S" and hit "F5" to run the page, the page will look as in the following image: Click on "Edit the Grid View", it will display Textboxes in each cell as in the following image: Edit the value(s) here and click on the Update link, it will update all the data or to remove it click on the "Delete" link above the image shown.
This enables you to provide an event-handling method that performs a custom routine, such as canceling the edit operation, whenever this event occurs.
A Grid View Edit Event Args object is passed to the event-handling method, which enables you to determine the index of the current row and to indicate that the edit operation should be canceled.
Now we define a method for opening a connection with the relation database and returns a SQL connection object depending on the connection string that is passed as a parameter of the Sql Connection class constructor.
Delete a Record We can delete a record from the database table by clicking on the delete button that is in the Delete column of the Grid View.