web app - datagrid - delete button - functionality?

Hi, I have a datagrid with a delete button column added to it.  I'm using the sub DBGrid1_DeleteCommand to access this button press.  I can't seem to find what index is being pointed to though.  DBGrid1.SelectedIndex isn't returning the row selected, DBGrid1.EditItemIndex isn't returning the row, and I don't see a DBGrid1.DeleteItemIndex - how do I get the row referenced by someone clicking the delete button on that row?  Or is there a simpler way to do this than I think?  I'm using basically:

   Private Sub DBGrid1_DeleteCommand(ByVal source As Object, ByVal e As System.Web.UI.WebControls.DataGridCommandEventArgs) Handles DBGrid1.DeleteCommand
        Dim selIndex As Integer = -1

        selIndex = (5 * (Session("GridPage")) + DBGrid1.SelectedIndex)
        Dim dr As DataRow
        dr = DS_UserSetup1.Tables(0).Rows(selIndex)
        DS_UserSetup1.Tables(0).Rows(selIndex).Delete()
        dr.EndEdit()

        Try
            ' When you call the update ADO.net will go through all the record that have a rowstate  'Modified' and will update that record
            SqlDataAdapter1.Update(DS_UserSetup1)
        Catch ex As Exception
            'MsgBox(ex.Message)
        End Try

        DS_UserSetup1.AcceptChanges()

        SqlDataAdapter1.Fill(DS_UserSetup1)

        DBGrid1.DataBind()

        CloseControls()
    End Sub

Thanks!

JP
gleznovAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

slightwv (䄆 Netminder) Commented:
Try:
response.write("You want to delete: " & e.Item.ItemIndex)
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
gleznovAuthor Commented:
ahhh, e.item.itemindex

Thanks!
0
slightwv (䄆 Netminder) Commented:
NP:  I can't tell you how many hours I've spent trying to figure out the obvious......
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic.NET

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.