For RowEditing event, you should look in the GridViewEditEventArgs parameter, it contains a property called NewEditIndex which reflects the row id of the row being edited. You can use the property like this:
void CustomersGridView_RowEditing(Object sender, GridViewEditEventArgs e)
{
String country = CustomersGridView.Rows[e.NewEditIndex].Cells[6].Text;
if (country == "USA")
{
// Cancel the edit operation.
e.Cancel = true;
Message.Text = "You cannot edit this record.";
}
else
{
Message.Text = "";
}
}
[Full code at MSDN: GridView.RowEditing Event]
Similarly, there's a GridViewDeleteEventArgs available in the RowDeleting event method that contains a RowIndex property.
If this post was useful to you, please mark it as answer. Thank you!