GridView Web Server Control Events

The GridView control raises a number of events in the course of paging through and updating its bound data to which your code can respond.

GridView Events

The GridView control exposes paging and sorting events, and events that occur when the current row is created or bound to data. Events are also raised when a command control such as a Button control that is included as part of the GridView control has been clicked. The following table describes the events exposed by the GridView control.

  • RowCommand
    Occurs when a button is clicked in the GridView control. This event is often used to perform a task when a button is clicked in the control.

  • PageIndexChanging
    Occurs when a pager button is clicked, but before the GridView control performs the paging operation. This event is often handled to cancel the paging operation.

  • PageIndexChanged
    Occurs when a pager button is clicked, but after the GridView control performs the paging operation. This event is commonly handled when you need to perform a task after the user navigates to a different page in the control.

  • SelectedIndexChanging
    Occurs when a row's Select button (a button with its CommandName property set to "Select") within a GridView control is clicked, but before the GridView control performs the select operation. This event is often handled to cancel the selection operation.

  • SelectedIndexChanged
    Occurs when a row's Select button within a GridView control is clicked, but after the GridView control performs the select operation. This event is often handled to perform a task after a row is selected in the control.

  • Sorting
    Occurs when the hyperlink to sort a column is clicked, but before the GridView control performs the sort operation. This event is often handled to cancel the sorting operation or to perform a custom sorting routine.

  • Sorted
    Occurs when the hyperlink to sort a column is clicked, but after the GridView control performs the sort operation. This event is commonly handled to perform a task after the user clicks on a hyperlink to sort a column.

  • RowDataBound
    Occurs when a row in the GridView control is bound to a data record. This event is often handled to modify the contents of a row when the row is bound to data.

  • RowCreated
    Occurs when a new row is created in the GridView control. This event is often handled to modify the layout or appearance of a row when the row is created.

  • RowDeleting
    Occurs when a row's Delete button (a button with its CommandName property set to "Delete") within a GridView control is clicked, but before the GridView control deletes the record from the data source. This event is often handled to cancel the deleting operation.

  • RowDeleted
    Occurs when a row's Delete button is within a GridView control clicked, but after the GridView control deletes the record from the data source. This event is often handled to check the results of the delete operation.

  • RowEditing
    Occurs when a row's Edit button (a button with its CommandName property set to "Edit") within a GridView control is clicked, but before the GridView control enters edit mode. This event is often handled to cancel the editing operation.

  • RowCancelingEdit
    Occurs when a row's Cancel button (a button with its CommandName property set to "Cancel") within a GridView control is clicked, but before the GridView control exits edit mode. This event is often handled to stop the cancel operation.

  • RowUpdating
    Occurs when a row's Update button (a button with its CommandName property set to "Update") within a GridView control is clicked, but before the GridView control updates the record. This event is often handled to cancel the updating operation.

  • RowUpdated
    Occurs when a row's Update button within a GridView control is clicked, but after the GridView control updates the record. This event is often handled to check the results of the update operation.

  • DataBound
    This event is inherited from the BaseDataBoundControl control and occurs after the GridView control has finished binding to the data source.

See Also

Reference

GridView Web Server Control Overview