YES, we can write any codes inside Row_Deleting event.
We have to give CommnadName = "Delete" in ItemTemplate, then in Gridview RowDeleting event we can write any code or perform any operations like below:-
Protected Sub grid_employee_details_RowDeleting(sender As Object,e As GridViewDeleteEventArgs) Handles GridView1.RowDeleting
//write insert statement/update statement as
Dim sql_query as String = "update employee_master set employee_name = 'vishal' where employee_id = 1 and status = 'AA'"
Dim con as New SqlConnection("ConnectionString")
Dim cmd as New SQLCommand(sql_query,con)
Dim row_affected as Integer = cmd.ExecuteNonQuery();
lbl_message.Visible = True;
lbl_message.Text = "Record Successfull Updated"
Aspx page code is as follows:-
<asp:Gridview id="grid_employee_details" runat="server">
<asp:Button id="btn_delete" runat="Server" CommandName="Delete" Text="Delete"></asp:Button>
<asp:Label id="lbl_message" runat="server" visible="False"></asp:Label>
Asked In: Many Interviews |