Solved

Delete row with different selected value in gridview

Posted on 2008-10-20
5
480 Views
Last Modified: 2013-11-27
Hi all, I need to be able to delete a row, while another row is selected and know the value of the deleting row, so I can pass that on to a DTS package.  I can get the selected row value with .selectedvalue, but how do I get the key values for the row being deleted??  I have looked through everything and only see the selected row's value.

VS 2005 using VB.Net
0
Comment
Question by:ratkinso666
[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
  • 3
  • 2
5 Comments
 
LVL 6

Expert Comment

by:M3mph15
ID: 22765245
Hi,
How do you choose which row is to be deleted?
You can access any data in any row by using the row's and cell's index.
e.g. Dim s As String = GridView1.Rows(1).Cells(2).Text
0
 

Author Comment

by:ratkinso666
ID: 22766515
In a plain drag and drop gridview, with a sql database...  To choose which row is deleted you hit the delete button.  I am not creating it in code-behind.  If you hit the select button then you can get the "SelectedValue" of the gridview, I am needing to know how to get the deleting value of the gridview..  I have followed this through several times, if I hit select on the gridview and then I hit delete from a different row, it does indeed delete the row you want to, but I need to know the key value for THAT row, NOT the selected row.  I am trying to pass that parameter to a DTS package so that it can delete the associated data from other tables.  Right now, if you hit SELECT and then hit DELETE it will work fine because I have the selected value by the person hitting select, but I don't want them to have to hit SELECT first...  right now they keep just hitting delete and that will delete the row they want to delete, but then passes the selected rows value to my DTS package and deletes all the data associated with the SELECTED row and not the DELETE row...  please let me know if that doesn't make sense...
0
 
LVL 6

Accepted Solution

by:
M3mph15 earned 500 total points
ID: 22773153
Ok i think i get what your saying. Try this. This will execute before the row is actually deleted:

Protected Sub GridView1_RowDeleting(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewDeleteEventArgs) Handles GridView1.RowDeleting
Dim i As Integer = e.RowIndex  'This will give you the index of the row being deleted
Dim s As String = GridView1.Rows(i).Cells(3).Text  'Using the index you can access the row and it's cells
'Then send value to your DTS package
End Sub
-M3mph15
0
 

Author Comment

by:ratkinso666
ID: 22780472
M3mph15, YES, that worked GREAT!!!
Thank you very much
0
 

Author Closing Comment

by:ratkinso666
ID: 31507983
Thank you again for your excellent help!!!
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

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

1.0 - Introduction Converting Visual Basic 6.0 (VB6) to Visual Basic 2008+ (VB.NET). If ever there was a subject full of murkiness and bad decisions, it is this one!   The first problem seems to be that people considering this task of converting…
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…

734 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