Solved

Find ID of deleted row in GridView

Posted on 2009-05-13
1
423 Views
Last Modified: 2013-11-27
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

0
Comment
Question by:dparkes
1 Comment
 
LVL 1

Accepted Solution

by:
dparkes earned 0 total points
ID: 24378889
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

0

Featured Post

Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Insert filename column as column a 18 76
SAPE.heur.AE935 Visual Studio 3 53
Build VS2015 project in bat command 3 93
Please explain the parts of these 2 LINQ expressions 3 53
This article surveys and compares options for encoding and decoding base64 data.  It includes source code in C++ as well as examples of how to use standard Windows API functions for these tasks. We'll look at the algorithms — how encoding and decodi…
Entering time in Microsoft Access can be difficult. An input mask often bothers users more than helping them and won't catch all typing errors. This article shows how to create a textbox for 24-hour time input with full validation politely catching …
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…

791 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question