Use the following steps.
1) assign ID's (Primary Key) to Gridview
2) Use Gridview Row Deleting event.(using Command name)
3) Get the ID of row clicked by user to Delete.
4) Use ID in delete sql query & execute sql command.
5) Bind Gridview after successful deletion of row.
Use the following code.
protected void gvAcceptanceStatus_RowDeleting(object sender, GridViewDeleteEventArgs e)
{
string ObvID =gvAcceptanceStatus.Rows[e.RowIndex].Cells[3].Text.ToString();
string ObvID=gvAcceptanceStatus.DataKeys[index].Values["ObservationID"].ToString();
conn.Open();
SqlCommand cmd = new SqlCommand("sp_DeleteInfo", conn);
cmd.CommandType = CommandType.StoredProcedure;
cmd.Parameters.AddWithValue("ID",ObvID);
try
{
cmd.ExecuteNonQuery();
}
catch (Exception ex)
{
throw new Exception("Exception adding account. " + ex.Message);
}
finally
{
conn.Close();
}
BindgvAcceptanceStatus();
}
In aspx page:-
<asp:gridview id="gvAcceptanceStatus" runat="server" autogeneratecolumns="False" datakeynames="ObservationID" onrowdeleting="gvAcceptanceStatus_RowDeleting">
Convert it to VB.NET.
Hope this helps. :)