?
Solved

Delete row with different selected value in gridview

Posted on 2008-10-20
5
Medium Priority
?
483 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 2000 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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Parsing a CSV file is a task that we are confronted with regularly, and although there are a vast number of means to do this, as a newbie, the field can be confusing and the tools can seem complex. A simple solution to parsing a customized CSV fi…
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
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 video we outline the Physical Segments view of NetCrunch network monitor. By following this brief how-to video, you will be able to learn how NetCrunch visualizes your network, how granular is the information collected, as well as where to f…

777 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