Find ID of deleted row in GridView

This codes loops through all the ID's, except the one I wish to identify (the row on which I have selected "Delete").  I need to identify the ID of the row being deleted.  If somone could point the way, I would be very much appreciative.
protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
        string selectedID = "";
        if (e.Row.RowType == DataControlRowType.DataRow)
            Button delete = (Button)e.Row.FindControl("delete");
            selectedID = GridView1.DataKeys[e.Row.RowIndex].Value.ToString();

Open in new window

Who is Participating?
dparkesConnect With a Mentor Author Commented:
Placing the following code under the RowDeleting event seems to have solved the issue.

string selectedID = "";
        try { selectedID = GridView1.Rows[Convert.ToInt16(e.RowIndex)].Cells[8].Text; }
        catch { }

Open in new window

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.