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
Solved

ASP.Net VB to delete row from gridview

Posted on 2011-09-19
2
475 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

Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

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

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…
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/…
Two types of users will appreciate AOMEI Backupper Pro: 1 - Those with PCIe drives (and haven't found cloning software that works on them). 2 - Those who want a fast clone of their boot drive (no re-boots needed) and it can clone your drive wh…
In an interesting question (https://www.experts-exchange.com/questions/29008360/) here at Experts Exchange, a member asked how to split a single image into multiple images. The primary usage for this is to place many photographs on a flatbed scanner…

856 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