Batch deletion in datagrid

osl

Member
Joined
Jun 8, 2006
Messages
20
Programming Experience
5-10
Hi,
How to do batch deletion from a datagrid (i.e. Click at Delete Button to delete all checked items at one go)?
I don't see CheckBox in the collection eventhough it's in the datagrid's column.
If the Delete button is in the grid of each item, it works.

Thanks in advance!
 
Try this,

Protected Sub grdvUser_RowDeleting(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewDeleteEventArgs) Handles grdvUser.RowDeleting
strUserId = e.Keys.Item(
"UserID")
'Deleting References or batch
DeleteUser()
'Deleting User
SqlDtSrc.DeleteCommand = "DELETE FROM ct_users Where UserID='" & e.Keys.Item("UserID") & "'"
End Sub

Best Regards,
Ashish Modi
ashishm@itechplanet.com
 
Dear Ashish,

Thanks for your help but I have few questions.
1) SqlDtSrc, is it data source? If yes, how to declare it?
2) Can share your codes for DeleteUser()?
3) '_RowDeleting' and 'System.Web.UI.WebControls.GridViewDeleteEventArgs' only found in VS2005? I'm using VS2003 and I can't find them but '
_DeleteCommand' and '
System.Web.UI.WebControls.DataGridCommandEventArgs
'
4) 'e.Keys is not member of System.Web.UI.WebControls.DataGridCommandEventArgs' when at my datagrid, its datakeyfield is UserId and key element at Dataset is also 'UserId'


Below are my codes:-
Private Sub DataGrid1_DeleteCommand(ByVal source As System.Object, ByVal e As System.Web.UI.WebControls.DataGridCommandEventArgs)
Dim strUserId As String
strUserId = e.Keys.Item("UserID") 'Deleting References or batch
DeleteUser()
SqlDtSrc.DeleteCommand = "DELETE FROM TblLogin Where UserID='" & e.Keys.Item("UserID") & "'"
End Sub
 
Hi osl, your primary platform says that you are using 2005 yet in your post you say you are using 2003. Could you amend your primary platform so that it correctly displays the version you are using, otherwise it can become very confusing and you may get incorrect information.
 
So sorry...I didn't realised my mistake as I'm still in the midst of testing out which version to use (VS2003 or VS2005). I was aiming to use VS2005, that must be the reason why I put VS2005 for primary platform.

I've changed my profile accordingly. Thanks!
 
Back
Top