Events in Grid view
Name
|
Description
| |
1
| ||
2
| ||
3
|
Occurs when a server control is released from memory, which is the last stage of the server control lifecycle when an ASP.NET page is requested. (Inherited from Control.)
| |
4
|
Occurs when the server control is initialized, which is the first step in its lifecycle. (Inherited from Control.)
| |
5
| ||
6
|
Occurs when one of the pager buttons is clicked, but after the GridView control handles the paging operation.
| |
7
|
Occurs when one of the pager buttons is clicked, but before the GridView control handles the paging operation.
| |
8
| ||
9
|
Occurs when the Cancel button of a row in edit mode is clicked, but before the row exits edit mode.
| |
10
| ||
11
| ||
12
| ||
13
| ||
14
| ||
15
| ||
16
| ||
17
| ||
18
|
Occurs when a row's Select button is clicked, but after the GridView control handles the select operation.
| |
19
|
Occurs when a row's Select button is clicked, but before the GridView control handles the select operation.
| |
20
|
Occurs when the hyperlink to sort a column is clicked, but after the GridView control handles the sort operation.
| |
21
|
Occurs when the hyperlink to sort a column is clicked, but before the GridView control handles the sort operation.
| |
22
|
DataBinding event
This event notifies the server control to perform any data-binding logic that has been written for it.
DataBound event
This event notifies the server control that any data binding logic written for it has completed.
Disposed event
Resources that require significant processor time, such as database connections, should be released with this event.
Init event
Server controls should perform any initialization steps that are required to create and set up an instance. You cannot use view-state information within this event; it is not populated yet. You should not access another server control during this event, regardless of whether it is a child or parent to this control. Other server controls are not certain to be created and ready for access.
Load event
Notifies the server control to perform any processing steps that are set to occur on each page request. You can access view state information and Web form POST data from this event. You can also access other server controls within the page's control hierarchy.
PageIndexChanged
The PageIndexChanged event is raised when one of the pager buttons is clicked, but after the GridView control handles the paging operation. This enables you to provide an event-handling method that performs a custom routine, such as a custom paging operation, whenever this event occurs.
To determine the index of the page selected by the user, use the PageIndex property of the GridView control.
PageIndexChanging event
The PageIndexChanging event is raised when one of the pager buttons is clicked, but before the GridView control handles the paging operation. This enables you to provide an event-handling method that performs a custom routine, such as canceling the paging operation, whenever this event occurs.
PreRender event
Use this event to perform any updates before the server control is rendered to the page. Any changes in the view state of the server control can be saved during this event. Such changes made in the rendering phase will not be saved.
RowCancelingEdit event
The RowCancelingEdit event is raised when the Cancel button of a row in edit mode is clicked, but before the row exits edit mode. This enables you to provide an event-handling method that performs a custom routine, such as stopping the cancel operation if it would put the row in an undesired state, whenever this event occurs.
A GridViewCancelEditEventArgs object is passed to the event-handling method, which enables you to determine the index of the current row and to indicate that the cancel operation should be stopped. To stop the cancel operation, set the Cancel property of the GridViewCancelEditEventArgs object to true.
RowCommand event
The RowCommand event is raised when a button is clicked in the GridView control. This enables you to provide an event-handling method that performs a custom routine whenever this event occurs.
Buttons within a GridView control can also invoke some of the built-in functionality of the control. To perform one of these operations, set the CommandName property of a button to one of the values in the following table.
CommandName value
|
Description
|
"Cancel"
|
Cancels an edit operation and returns the GridView control to read-only mode. Raises the RowCancelingEdit event.
|
"Delete"
| |
"Edit"
| |
"Page"
|
Performs a paging operation. Sets the CommandArgument property of the button to "First", "Last", "Next", "Prev", or a page number to specify the type of paging operation to perform. Raises the PageIndexChanging and PageIndexChanged events.
|
"Select"
| |
"Sort"
| |
"Update"
|
Although the RowCommand event is raised when a button listed in the previous table is clicked, it is recommended that you use the events listed in the table for the operation.
A GridViewCommandEventArgs object is passed to the event-handling method, which enables you to determine the command name and command argument of the button clicked.
RowCreated event
Before the GridView control can be rendered, a GridViewRow object must be created for each row in the control. The RowCreated event is raised when each row in the GridView control is created. This enables you to provide an event-handling method that performs a custom routine, such as adding custom content to a row, whenever this event occurs.
A GridViewRowEventArgs object is passed to the event-handling method, which enables you to access the properties of the row being created. To access a specific cell in the row, use the Cells property of the GridViewRowEventArgs object. You can determine which row type (header row, data row, and so on) is being created by using the RowType property.
RowDataBound event
Before the Grid View control can be rendered, each row in the control must be bound to a record in the data source. The RowDataBound event is raised when a data row (represented by a GridViewRow object) is bound to data in the GridView control. This enables you to provide an event-handling method that performs a custom routine, such as modifying the values of the data bound to the row, whenever this event occurs.
A GridViewRowEventArgs object is passed to the event-handling method, which enables you to access the properties of the row being bound. To access a specific cell in the row, use the Cells property of the GridViewRow object contained in the Row property of the GridViewRowEventArgs object. You can determine which row type (header row, data row, and so on) is being bound by using the RowType property.
RowDeleted event
The RowDeleted event is raised when a row's Delete button is clicked, but after the GridView control deletes the row. This enables you to provide an event-handling method that performs a custom routine, such as checking the results of the delete operation, whenever this event occurs.
A GridViewDeletedEventArgs object is passed to the event-handling method, which enables you to determine the number of rows affected and any exceptions that might have occurred. You can also indicate whether the exception was handled in the event-handling method by setting the ExceptionHandled property of the GridViewDeletedEventArgs object.
RowDeleting event
The RowDeleting event is raised when a row's Delete button is clicked, but before the GridView control deletes the row. This enables you to provide an event-handling method that performs a custom routine, such as canceling the delete operation, whenever this event occurs.
A GridViewDeleteEventArgs object is passed to the event-handling method, which enables you to determine the index of the current row and to indicate that the delete operation should be canceled. To cancel the delete operation, set the Cancel property of the GridViewDeleteEventArgs object to true. You can also manipulate the Keys and Values collections, if necessary, before the values are passed to the data source.
RowEditing event
The RowEditing event is raised when a row's Edit button is clicked, but before the GridView control enters edit mode. This enables you to provide an event-handling method that performs a custom routine, such as canceling the edit operation, whenever this event occurs.
A GridViewEditEventArgs object is passed to the event-handling method, which enables you to determine the index of the current row and to indicate that the edit operation should be canceled. To cancel the edit operation, set the Cancel property of the GridViewEditEventArgs object to true.
RowUpdated event
The RowUpdated event is raised when a row's Update button is clicked, but after the GridView control updates the row. This enables you to provide an event-handling method that performs a custom routine, such as checking the results of the update operation, whenever this event occurs.
A GridViewUpdatedEventArgs object is passed to the event-handling method, which enables you to determine the number of rows affected and any exceptions that might have occurred. You can also indicate whether the exception was handled in the event-handling method by setting the ExceptionHandled property of the GridViewUpdatedEventArgs object.
RowUpdating event
The RowUpdating event is raised when a row's Update button is clicked, but before the GridView control updates the row. This enables you to provide an event-handling method that performs a custom routine, such as canceling the update operation, whenever this event occurs.
A GridViewUpdateEventArgs object is passed to the event-handling method, which enables you to determine the index of the current row and to indicate that the update operation should be canceled. To cancel the update operation, set the Cancel property of the GridViewUpdateEventArgs object to true. You can also manipulate the Keys, OldValues, and NewValues collections, if necessary, before the values are passed to the data source. A common way to use these collections is to HTML-encode the values supplied by the user before they are stored in the data source. This helps to prevent script injection attacks.
SelectedIndexChanged event
The SelectedIndexChanged event is raised when a row's Select button is clicked, but after the GridView control handles the select operation. This enables you to provide an event-handling method that performs a custom routine, such as updating a status label with the currently selected row, whenever this event occurs.
SelectedIndexChanging event
The SelectedIndexChanging event is raised when a row's Select button is clicked, but before the GridView control handles the select operation. This enables you to provide an event-handling method that performs a custom routine, such as canceling the selection operation, whenever this event occurs.
A GridViewSelectEventArgs object is passed to the event-handling method, which enables you to determine the index of the row selected by the user and to indicate that the selection operation should be canceled. To cancel the selection operation, set the Cancel property of the GridViewSelectEventArgs object to true.
Sorted event
The Sorted event is raised when the hyperlink to sort a column is clicked, but after the GridView control handles the sort operation. This enables you to provide an event-handling method that performs a custom routine, such as custom sorting, whenever this event occurs.
Sorting event
The Sorting event is raised when the hyperlink to sort a column is clicked, but before the GridView control handles the sort operation. This enables you to provide an event-handling method that performs a custom routine, such as canceling the sorting operation, whenever this event occurs.
A GridViewSortEventArgs object is passed to the event-handling method, which enables you to determine the sort expression for the column and to indicate that the selection operation should be canceled. To cancel the selection operation, set the Cancel property of the GridViewSortEventArgs object to true.
Unload event
Server controls must perform any final clean-up, such as closing files, database connections and discarding objects, during this stage of the control lifecycle before the instance is unloaded.
No comments:
Post a Comment