System.Web.UI.WebControls Namespace
Renders a column in a DataGrid that allows editing data items within the selected row.
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.
Show me
DataGrid BoundColumn ButtonColumn HyperLinkColumn TemplateColumn