asp.net.ph

Skip Navigation Links

Responding to Control Events in GridView Rows

Controls You Can Use on Web Forms   ASP.NET Data Controls   GridView Control


The GridView control provides several events that you can program against. This allows you to run a custom routine whenever an event occurs. The following table lists the events supported by the GridView control.

Event Description
PageIndexChanged Occurs when one of the pager buttons is clicked, but after the GridView control handles the paging operation. This event is commonly used when you need to perform a task after the user navigates to a different page in the control.
PageIndexChanging Occurs when one of the pager buttons is clicked, but before the GridView control handles the paging operation. This event is often used to cancel the paging operation.
RowCancelingEdit Occurs when a row’s Cancel button is clicked, but before the GridView control exits edit mode. This event is often used to stop the canceling operation.
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.
RowCreated Occurs when a new row is created in the GridView control. This event is often used to modify the contents of a row when the row is created.
RowDataBound Occurs when a data row is bound to data in the GridView control. This event is often used to modify the contents of a row when the row is bound to data.
RowDeleted Occurs when a row’s Delete button is clicked, but after the GridView control deletes the record from the data source. This event is often used to check the results of the delete operation.
RowDeleting Occurs when a row’s Delete button is clicked, but before the GridView control deletes the record from the data source. This event is often used to cancel the deleting operation.
RowEditing Occurs when a row’s Edit button is clicked, but before the GridView control enters edit mode. This event is often used to cancel the editing operation.
RowUpdated Occurs when a row’s Update button is clicked, but after the GridView control updates the row. This event is often used to check the results of the update operation.
RowUpdating Occurs when a row’s Update button is clicked, but before the GridView control updates the row. This event is often used to cancel the updating operation.
SelectedIndexChanged Occurs when a row’s Select button is clicked, but after the GridView control handles the select operation. This event is often used to perform a task after a row is selected in the control.
SelectedIndexChanging Occurs when a row’s Select button is clicked, but before the GridView control handles the select operation. This event is often used to cancel the selection operation.
Sorted Occurs when the hyperlink to sort a column is clicked, but after the GridView control handles the sort operation. This event is commonly used to perform a task after the user clicks on a hyperlink to sort a column.
Sorting Occurs when the hyperlink to sort a column is clicked, but before the GridView control handles the sort operation. This event is often used to cancel the sorting operation or to perform a custom sorting routine.

See Also

Introduction to the GridView Control   Adding GridView Controls to a Web Forms Page   Web Forms Events and Handlers



© 2025 Reynald Nuñez and asp.net.ph. All rights reserved.

If you have any question, comment or suggestion
about this site, please send us a note