Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

ASP.Net VB to delete row from gridview

Posted on 2011-09-19
2
Medium Priority
?
493 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 2000 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

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

Today is the age of broadband.  More and more people are going this route determined to experience the web and it’s multitude of services as quickly and painlessly as possible. Coupled with the move to broadband, people are experiencing the web via …
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
This video shows how to quickly and easily deploy an email signature for all users in Office 365 and prevent it from being added to replies and forwards. (the resulting signature is applied on the server level in Exchange Online) The email signat…
Despite its rising prevalence in the business world, "the cloud" is still misunderstood. Some companies still believe common misconceptions about lack of security in cloud solutions and many misuses of cloud storage options still occur every day. …

927 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