[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 219
  • Last Modified:

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
0
gleznov
Asked:
gleznov
  • 2
1 Solution
 
slightwv (䄆 Netminder) Commented:
Try:
response.write("You want to delete: " & e.Item.ItemIndex)
0
 
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

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now