Solved

Find ID of deleted row in GridView

Posted on 2009-05-13
1
420 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

Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

Join & Write a Comment

As more and more people are shifting to the latest .Net frameworks, the windows presentation framework is gaining importance by the day. Many people are now turning to WPF controls to provide a rich user experience. I have been using WPF controls fo…
Whether you've completed a degree in computer sciences or you're a self-taught programmer, writing your first lines of code in the real world is always a challenge. Here are some of the most common pitfalls for new programmers.
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…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

758 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

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now