Wrox Programmer Forums
|
VS.NET 2002/2003 Discussions about the Visual Studio.NET programming environment, the 2002 (1.0) and 2003 (1.1). ** Please don't post code questions here ** For issues specific to a particular language in .NET, please see the other forum categories.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the VS.NET 2002/2003 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old April 15th, 2004, 05:36 AM
Registered User
 
Join Date: Apr 2004
Posts: 8
Thanks: 0
Thanked 0 Times in 0 Posts
Default checkbox in datagrid and delete

Hello...

I have checkbox in my datagrid. The checkbox is for the user to check and clicks on the delete button (which is not in the datagrid). And it will delete that row of the datagrid. I need to use e.Item.Cell(1) to retrieve the id from the datagrid so that i can delete my data belongs to the id. But I do not know how to code it.

I only know that if the user check the checkbox, it will become true in my codes.

Here is bits of my code:

Private Sub btnRemove_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnRemove.Click

        Dim oDataGridItem As DataGridItem
        Dim chkRemove As System.Web.UI.WebControls.CheckBox
        Dim strItemID As String
        Dim strItemIDCell As TableCell = e.Item.Cells(1)
        Dim strItemID As String = strItemIDCell.Text

        For Each oDataGridItem In dgReCart.Items

            chkRemove = oDataGridItem.FindControl("chkDelete")
            If chkRemove.Checked Then
                bl.DeleteItemFrCart(strItemID)
                RefreshGrid()
            End If
        Next
    End Sub

So, how am I going to solve this problems. As the eventargs is not DataGridCommandEventArgs.
 
Old April 16th, 2004, 03:32 PM
planoie's Avatar
Friend of Wrox
 
Join Date: Aug 2003
Posts: 5,407
Thanks: 0
Thanked 16 Times in 16 Posts
Default

See this thread for the answer. Please don't cross post. If you need to you can delete a post or thread you create.
 
Old May 21st, 2004, 12:00 AM
Authorized User
 
Join Date: Apr 2004
Posts: 14
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Yahoo to kekohchaa
Default

Dear Saman,
Try this:-
Private Sub cmdDelete_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdHapus.Click
        Dim dgItem As DataGridItem

        For Each dgItem In DataGrid1.Items
            Dim chkDelete As CheckBox = dgItem.FindControl("chkDelete ")
            Dim IDDelete As Integer = CType(dgItem.FindControl("lblNoBorang"), Label).Text
            Dim strSQL As String

            If chkDelete .Checked = True Then
                objConn = New SqlConnection(ConfigurationSettings.AppSettings("c onnMIOS"))
                objConn.Open()
                strSQL = "DELETE FROM DomestikPengesahanTerima WHERE NoBorang = " & IDDelete & " "
                sqlcmd = New SqlCommand(strSQL, objConn)
                sqlcmd.ExecuteNonQuery()
                objConn.Close()

            End If
        Next

        bindDataSet()
        bind()
    End Sub






Similar Threads
Thread Thread Starter Forum Replies Last Post
How i can delete with checkbox maz_alaameri ASP.NET 1.0 and 1.1 Basics 1 December 5th, 2006 05:14 AM
In datagrid when checkbox true delete in btn click ashish2001mca ASP.NET Espanol 1 January 9th, 2006 08:45 AM
how delete row in datagrid which check checkbox ashish2001mca Forum and Wrox.com Feedback 1 September 18th, 2005 03:43 AM
Desperate!!!! DataGrid w/checkbox for Delete fitchic77 .NET Framework 2.0 7 August 5th, 2004 09:27 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.