Click to See Complete Forum and Search --> : Delete using checkboxes
Funkymonkey
08-16-2005, 09:49 AM
Anyoe know of a good on-line tutorial? I need to have a checkbox next to all my records so you can select as many as you kine and then delete them from the database.
Also, can someone tell me if I can just use a datagrid to display the info or will I need a repeater control???
Thanks
A1ien51
08-16-2005, 10:55 AM
You can use a datagrid...
The code is something like this to find the checkbox and delete a row.
Dim iRowsDeleted as Integer = 0
For Each dr In dgName.Items
chkDelete = CType(dr.FindControl("chkDelete"), CheckBox)
If chkDelete.Checked = True Then
iRowsDeleted += 1
ds.Tables("TableName").Rows(dr.ItemIndex - iRowsDeleted).Delete()
End If
Next
Eric
Funkymonkey
08-16-2005, 11:15 AM
Thank you but what is the dr? I thought it was datarow but it doesn't seem to like it?
Thank you loads!
A1ien51
08-16-2005, 12:03 PM
It should be:
Dim dr As DataGridItem
If I remember correctly. Writing this off the top of my head.
Eric
Funkymonkey
08-17-2005, 02:39 AM
And Dim chk as Checkbox???
A1ien51
08-17-2005, 06:47 AM
Dim chkDelete As checkbox = CType(dr.FindControl("chkDelete"), CheckBox)
brendalisalowe
10-23-2005, 06:25 PM
Just wondering if you ever got that to work? I am doing the same thing, but something with my post back won't let it work. Any ideas why?