?
Solved

Find ID of deleted row in GridView

Posted on 2009-05-13
1
Medium Priority
?
427 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

New benefit for Premium Members - Upgrade now!

Ready to get started with anonymous questions today? It's easy! Learn more.

Question has a verified solution.

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

This article shows how to make a Windows 7 gadget that accepts files dropped from the Windows Explorer.  It also illustrates how to give your gadget a non-rectangular shape and how to add some nifty visual effects to text displayed in a your gadget.…
This article describes how to programmatically preset the "Pages per Sheet" option that's available with most printer drivers.   This setting lets you do "n-Up" printing, where two, four, or more pages are printed on each sheet of paper. If your …
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…
In this brief tutorial Pawel from AdRem Software explains how you can quickly find out which services are running on your network, or what are the IP addresses of servers responsible for each service. Software used is freeware NetCrunch Tools (https…

765 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