Delete using checkboxes

liunx

Guest
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???

ThanksYou 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


EricThank you but what is the dr? I thought it was datarow but it doesn't seem to like it?

Thank you loads!It should be:

Dim dr As DataGridItem

If I remember correctly. Writing this off the top of my head.

EricAnd Dim chk as Checkbox???Dim chkDelete As checkbox = CType(dr.FindControl("chkDelete"), CheckBox)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?
 
Back
Top