How to Delete Items in a DataGrid Web Server Control

Discussion in 'ASP .Net Datagrid Control' started by tom c, Jun 7, 2006.

  1. tom c

    tom c Guest

    In this walkthrough on "Allowing Users to Delete Items in a DataGrid
    Web Server Control" at:

    ms-help://MS.VSCC.2003/MS.MSDNQTR.2003FEB.1033/vbcon/html/vbtskallowinguserstodeleteitemsindatagridwebcontrol.htm

    it leaves out some very important code. Here is what it gives you:

    ' Visual Basic
    Private Sub DataGrid1_DeleteCommand(ByVal source As Object, _
    ByVal e As System.Web.UI.WebControls.DataGridCommandEventArgs) _
    Handles DataGrid1.DeleteCommand
    Dim index As Integer
    index = e.Item.ItemIndex
    ' Add code to delete data from data source.
    DataGrid1.DataBind()
    End Sub

    Where is says "Add code to delete data from data source" I have no idea
    what to add. Can someone tell me what goes there, or point me to a
    walkthough or example that goes into more detail?
    tom c, Jun 7, 2006
    #1
    1. Advertising

  2. LOL...

    it says: Add code to delete data from data source

    so, add the code to delete the row you what! How easy could it be?
    it give you the ID from that row in the index variable... if your data is in
    the database use something like

    "DELETE FROM table WHERE idRow = @index"
    and bind the parameter @index to the index variable

    ....
    r u using 1.x or 2.0?

    --

    Bruno Alexandre
    (a Portuguese in KĂžbenhanv, Danmark)


    "tom c" <> escreveu na mensagem
    news:...
    > In this walkthrough on "Allowing Users to Delete Items in a DataGrid
    > Web Server Control" at:
    >
    > ms-help://MS.VSCC.2003/MS.MSDNQTR.2003FEB.1033/vbcon/html/vbtskallowinguserstodeleteitemsindatagridwebcontrol.htm
    >
    > it leaves out some very important code. Here is what it gives you:
    >
    > ' Visual Basic
    > Private Sub DataGrid1_DeleteCommand(ByVal source As Object, _
    > ByVal e As System.Web.UI.WebControls.DataGridCommandEventArgs) _
    > Handles DataGrid1.DeleteCommand
    > Dim index As Integer
    > index = e.Item.ItemIndex
    > ' Add code to delete data from data source.
    > DataGrid1.DataBind()
    > End Sub
    >
    > Where is says "Add code to delete data from data source" I have no idea
    > what to add. Can someone tell me what goes there, or point me to a
    > walkthough or example that goes into more detail?
    >
    Bruno Alexandre, Jun 8, 2006
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Matthew Louden
    Replies:
    1
    Views:
    6,885
    Scott M.
    Oct 11, 2003
  2. Gilles Kuhn
    Replies:
    0
    Views:
    426
    Gilles Kuhn
    Sep 15, 2003
  3. Bart Van Hemelen
    Replies:
    2
    Views:
    4,654
    Bart Van Hemelen
    Sep 4, 2006
  4. Fred Zolar
    Replies:
    0
    Views:
    210
    Fred Zolar
    Apr 1, 2004
  5. Henrik
    Replies:
    1
    Views:
    416
    Ken Cox [Microsoft MVP]
    Jul 6, 2006
Loading...

Share This Page