Solved

Delete row with different selected value in gridview

Posted on 2008-10-20
5
476 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
  • 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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Suggested Solutions

Introduction When many people think of the WebBrowser (http://msdn.microsoft.com/en-us/library/2te2y1x6%28v=VS.85%29.aspx) control, they immediately think of a control which allows the viewing and navigation of web pages. While this is true, it's a…
What my article will show is if you ever had to do processing to a listbox without being able to just select all the items in it. My software Visual Studio 2008 crystal report v11 My issue was I wanted to add crystal report to a form and show…
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…
This tutorial demonstrates a quick way of adding group price to multiple Magento products.

760 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

16 Experts available now in Live!

Get 1:1 Help Now