This is a migrated thread and some comments may be shown as answers.

Delete Button in Gridview Doesn't fire UserDeletingRow event?

1 Answer 408 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Imo
Top achievements
Rank 1
Imo asked on 15 Jul 2012, 09:05 AM
Hello guys i have a problem regarding my RadButtonElement.
I have this RadButtonElement inside my GridViewCommandColumn.
here is my Code:
Private Sub rgvSKUDetails_CommandCellClick(sender As System.Object, e As System.EventArgs) Handles rgvSKUDetails.CommandCellClick
       If TypeOf rgvSKUDetails.CurrentRow Is Telerik.WinControls.UI.GridViewNewRowInfo Then
           Exit Sub
       End If
       rgvSKUDetails.Rows.RemoveAt(rgvSKUDetails.CurrentRow.Index)
   End Sub

I was Expecting that this CommandcellClick event will fire the.

Public Sub rgvSKUDetails_UserDeletingRow(sender As System.Object, e As Telerik.WinControls.UI.GridViewRowCancelEventArgs) Handles rgvSKUDetails.UserDeletingRow
Msgbox("Why Did you delete it?")
'This section here, im supposed to update the database that the
record has been deleted, but since this event is not firing is
there anyway that i could capture the event so i could update the database
that the user deleted the record?
'Perform Update to database
End Sub
i needed it because i want to update the database that the particular row was deleted by the user.

Thanks IMO

1 Answer, 1 is accepted

Sort by
0
Nikolay
Telerik team
answered on 16 Jul 2012, 11:36 AM
Hello Imo,

The User events are fired when end-user operations natively supported by RadGridView occur. For example, the UserDeletingRow will be fired when the end-user presses the DEL key to delete a row. In your particular case, however, you are deleting a row through code and not by an internally supported end-user operation. Therefore, you should use the RowsChanged event, for example:

Private Sub RadGridView_RowsChanged(sender As Object, e As GridViewCollectionChangedEventArgs)
    If e.Action = Telerik.WinControls.Data.NotifyCollectionChangedAction.Remove Then
           MsgBox("Why Did you delete it?") 
        'update db
    End If
End Sub

I hope this helps.

Kind regards,
Nikolay
the Telerik team
RadControls for WinForms Q2'12 release is now live! Check out what's new or download a free trial >>
Tags
GridView
Asked by
Imo
Top achievements
Rank 1
Answers by
Nikolay
Telerik team
Share this question
or