The GridView.RowDeleting event occurs when a GridView row's Delete button is clicked, but before the GridView control deletes the row. Handling this event helps you to display details of the row, cancel the delete operation or to perform some checks before the row is deleted.
C#
protected void GV_RowDeleting(object sender, GridViewDeleteEventArgs e)
{
int ID = (int)GV.DataKeys[e.RowIndex].Value;
// If you want to cancel the delete operation, you
// can do so by saying e.Cancel = true;
}
VB.NET
Protected Sub GV_RowDeleting(ByVal sender As Object, _
ByVal e As GridViewDeleteEventArgs)
Dim ID As Integer = CInt(GV.DataKeys(e.RowIndex).Value)
' If you want to cancel the delete operation, you
' can do so by saying e.Cancel = true;
End Sub
A GridViewDeleteEventArgs object is passed to the event-handling method, which enables you to determine the index of the current row as well as cancel the delete operation, as shown in the code above.
Tweet
No comments:
Post a Comment