System.Web.UI.WebControls Namespace GridView Class
.NET Framework version 2.0
Occurs when a Delete command button within a GridView control is clicked, but before the delete operation.
[ VB ]
Public Event RowDeleting As GridViewDeleteEventHandler
[ C# ]
public event GridViewDeleteEventHandler RowDeleting;
[ C++ ]
public: __event GridViewDeleteEventHandler* RowDeleting;
In [ JScript ], you can handle the events defined by a class, but you cannot define your own.
The RowDeleting event is raised whenever a Delete button associated with an item in the GridView control is clicked, but before the GridView control deletes the record.
This allows you to provide an event-handling method that performs a custom routine, such as verifying a record before deleting it, whenever this event occurs.
Information related to the RowDeleting event is passed via a GridViewDeleteEventArgs object to the method assigned to handle the event. The following GridViewDeleteEventArgs properties provide information specific to this event.
Property |
Description |
Cancel |
Gets or sets a value indicating whether the event should be canceled ( inherited from CancelEventArgs ) |
Keys |
Gets an ordered dictionary of key field name/value pairs for the record to delete. |
RowIndex |
Gets the index of the record being deleted from the data source. |
Values |
Gets a dictionary of the non-key field name/value pairs for the item to delete. |
The following example demonstrates how to code a handler for the RowDeleting event to delete a single item from a GridView control.
WARNING: Deleting rows in a database table CANNOT BE UNDONE, which can result in serious data loss. In a real-world scenario, only the database administrator or an authorized user must be granted DELETE permission. The examples provided here are only for learning purposes.
GridView Members Allowing Users to Delete Rows in a GridView Control