| ||||||||||||||||||||||||||||||||||||||||||||||
EditCommandColumn ClassSystem.Web.UI.WebControls Namespace Renders a column in a DataGrid that allows editing data items within the selected row.
|
||||||||||||||||||||||||||||||||||||||||||||||
| Visibility | Name | Value Type | Accessibility |
|---|---|---|---|
| public | ButtonType | ButtonColumnType | [ Get , Set ] |
| public | CancelText | String | [ Get , Set ] |
| public | CausesValidation | Boolean | [ Get , Set ] |
| public | EditText | String | [ Get , Set ] |
| public | UpdateText | String | [ Get , Set ] |
| public | ValidationGroup | String | [ Get , Set ] |
| Visibility | Name | Parameters | Return Type |
|---|---|---|---|
| public | InitializeCell | ( TableCell cell , Int32 columnIndex , ListItemType itemType ) | Void |
Use the EditCommandColumn class to create a special column for the DataGrid control that contains Edit, Update, and Cancel command buttons for each data row in the grid. These buttons allow users to edit the values of a row in the DataGrid control.
The buttons in the EditCommandColumn can be set to display as hyperlinks or push buttons by setting the ButtonType property.
NOTE: You must provide values for the CancelText, EditText, and UpdateText properties. Otherwise, the associated command buttons will not appear in the EditCommandColumn.
If no row is selected, an Edit command button displays in the EditCommandColumn for each data row in the DataGrid control.
When any of the Edit buttons in the grid is clicked, an EditCommand event is raised. This provides a means to identify the row, but it is up to you to define code to handle the event. A typical event handler sets the EditItemIndex property to the selected row and then rebinds the data to the DataGrid control.
When the grid is in edit mode ( EditItemIndex is set to a specific row ), Update and Cancel command buttons appear in place of the Edit button for that row.
Clicking the Update or Cancel command button raises the UpdateCommand or CancelCommand event, respectively. Likewise, this provides a means to identify the row, but it is up to you to define code to handle these events.
A typical handler for the UpdateCommand event updates the data, sets the EditItemIndex property to -1 ( to deselect the item ), and then rebinds the data to the DataGrid control.
A typical handler for the CancelCommand event sets the EditItemIndex property to -1 ( to deselect the item ) and then rebinds the data to the DataGrid control.
The following example demonstrates using an EditCommandColumn to enable users to modify values within a row of the DataGrid control.
DataGrid BoundColumn ButtonColumn HyperLinkColumn TemplateColumn
Check out related books at Amazon
© 2000-2008 Rey Nuñez All rights reserved.
If you have any question, comment or suggestion
about this site, please send us a note
You can help support aspxtreme