Solved

Delete row with different selected value in gridview

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

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

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

Suggested Solutions

Title # Comments Views Activity
ASP/VB email question 4 46
VB.Net WebRequest Code from JSON curl 7 53
VB.NET 2008 Publish Error 2 34
VB.net Duplicating a table - primary key not created 3 32
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…
A theme is a collection of property settings that allow you to define the look of pages and controls, and then apply the look consistently across pages in an application. Themes can be made up of a set of elements: skins, style sheets, images, and o…
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…
Established in 1997, Technology Architects has become one of the most reputable technology solutions companies in the country. TA have been providing businesses with cost effective state-of-the-art solutions and unparalleled service that is designed…

828 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