Solved

ASP.Net VB to delete row from gridview

Posted on 2011-09-19
2
473 Views
Last Modified: 2012-06-21
Hi

I have a page with a dynamically created grid view.  I have added AutoGenerateDeleteButton = true and AddHandler myGridview.RowDeleting, AddressOf Me.gvrowdel

The problem I have is I cant figure out how to reference the datakeynames value for the row that was clicked to delete the correct line in my sql.

If it was a GridViewCommandEventArgs I would use something like the below:
(GridView1.DataKeys(Convert.ToInt32(e.CommandArgument)).Value)
However this is not a part of the GridViewDeleteEventArgs.

There is the e.rowindex which returns the row I clicked but I'm unsure how to use this to get the value of cell(1) (which is my ID/datakeys value)

Can any one help.

Thanks

Brasso






0
Comment
Question by:brasso_42
2 Comments
 
LVL 4

Accepted Solution

by:
Moizsaif123 earned 500 total points
ID: 36561653
try this,
GridView1.Rows(e.RowIndex).Cells(0).Text


there is more information on this regarding the rowdeleting event

http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.gridview.rowdeleting.aspx
0
 
LVL 1

Author Closing Comment

by:brasso_42
ID: 36565741
Awsome thanks
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

The ECB site provides FX rates for major currencies since its inception in 1999 in the form of an XML feed. The files have the following format (reducted for brevity) (CODE) There are three files available HERE (http://www.ecb.europa.eu/stats/exch…
This demonstration started out as a follow up to some recently posted questions on the subject of logging in: http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/Q_28634665.html and http://www.experts-exchange.com/Programming/…
In this video I am going to show you how to back up and restore Office 365 mailboxes using CodeTwo Backup for Office 365. Learn more about the tool used in this video here: http://www.codetwo.com/backup-for-office-365/ (http://www.codetwo.com/ba…
Both in life and business – not all partnerships are created equal. As the demand for cloud services increases, so do the number of self-proclaimed cloud partners. Asking the right questions up front in the partnership, will enable both parties …

863 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

24 Experts available now in Live!

Get 1:1 Help Now