Results 1 to 3 of 3

Thread: Desperate help !!

  1. #1

    Thread Starter
    Member
    Join Date
    Feb 2004
    Posts
    47

    Desperate help !!

    Hiya Im really stuck on doing the multiple delete checkbox.. I would really appreciate if anyone could help me out. Basically I am doing on a datagid whereby it display all the customers particulars and users can choose to delete one or more customers by using the checkbox and finally click on the delete linkbutton.

    I have a query, do i have to use dataset for this? Hope that someone can point out my mistake. Thankz...

    Below is my coding:

    Private Sub dgDelMember_ItemCommand(ByVal source As Object, ByVal e As System.Web.UI.WebControls.DataGridCommandEventArgs) Handles dgDelMember.ItemCommand


    Dim dgItem As DataGridItem
    Dim dr As DataRow
    Dim ds As New DataSet
    Dim result As String

    For Each dgItem In dgDelMember.Items
    'Identify row in dataset to update
    'dr = ds.Tables("Member").Rows.Find(dgDelMember.DataKeys(dgItem.ItemIndex))

    If CType(dgItem.FindControl("chkMemDelete"), CheckBox).Checked And e.CommandName = "DeleteButton" Then

    'ds.Tables("CustID").Rows.Remove(dr)

    Dim conn As OleDbConnection
    Dim objCmd As New OleDbCommand

    Session("Chk_CustID") = CType(dgItem.FindControl("chkMemDelete"), CheckBox).Text

    conn = connectToDB()
    objCmd.CommandText = "spDelMembers"
    objCmd.CommandType = CommandType.StoredProcedure
    objCmd.Connection = conn

    objCmd.Parameters.Add("@CustID", Session("Chk_CustID"))

    ' Execute SQL and read data from database
    objCmd.ExecuteNonQuery()

    ' Bind the records to the data list control
    dgDelMember.DataBind()

    ' Close the connection object
    conn.Close()
    End If
    Next
    End Sub

  2. #2
    l33t! MrPolite's Avatar
    Join Date
    Sep 2001
    Posts
    4,428

    Re: Desperate help !!

    umm try to enclose your code in [vbcode] and [/vbcode] tags:
    and sorry but I dont know the answer


    VB Code:
    1. Private Sub dgDelMember_ItemCommand(ByVal source As Object, ByVal e As System.Web.UI.WebControls.DataGridCommandEventArgs) Handles dgDelMember.ItemCommand
    2.  
    3.  
    4. Dim dgItem As DataGridItem
    5. Dim dr As DataRow
    6. Dim ds As New DataSet
    7. Dim result As String
    8.  
    9. For Each dgItem In dgDelMember.Items
    10. 'Identify row in dataset to update
    11. 'dr = ds.Tables("Member").Rows.Find(dgDelMember.DataKeys(dgItem.ItemIndex))
    12.  
    13. If CType(dgItem.FindControl("chkMemDelete"), CheckBox).Checked And e.CommandName = "DeleteButton" Then
    14.  
    15. 'ds.Tables("CustID").Rows.Remove(dr)
    16.  
    17. Dim conn As OleDbConnection
    18. Dim objCmd As New OleDbCommand
    19.  
    20. Session("Chk_CustID") = CType(dgItem.FindControl("chkMemDelete"), CheckBox).Text
    21.  
    22. conn = connectToDB()
    23. objCmd.CommandText = "spDelMembers"
    24. objCmd.CommandType = CommandType.StoredProcedure
    25. objCmd.Connection = conn
    26.  
    27. objCmd.Parameters.Add("@CustID", Session("Chk_CustID"))
    28.  
    29. ' Execute SQL and read data from database
    30. objCmd.ExecuteNonQuery()
    31.  
    32. ' Bind the records to the data list control
    33. dgDelMember.DataBind()
    34.  
    35. ' Close the connection object
    36. conn.Close()
    37. End If
    38. Next
    39. End Sub
    rate my posts if they help ya!
    Extract thumbnail without reading the whole image file: (C# - VB)
    Apply texture to bitmaps: (C# - VB)
    Extended console library: (VB)
    Save JPEG with a certain quality (image compression): (C# - VB )
    VB.NET to C# conversion tips!!

  3. #3

    Thread Starter
    Member
    Join Date
    Feb 2004
    Posts
    47
    Thankz...

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width