DekGenius.com
[ Team LiB ] Previous Section Next Section

EditCommandColumn

System.Web.UI.WebControls (system.web.dll)class

The EditCommandColumn class is a special type of column used with the DataGrid control. It provides an "Edit" button or link (depending on the ButtonType property) that, when clicked, fires the DataGrid.EditCommand event. This event allows you to initiate editing for a row by using the DataGrid.EditItemIndex property (after which you must rebind to the data source).

While editing is in progress, the EditCommandColumn displays "Cancel" and "Update" buttons instead of an "Edit" button. These will trigger the DataGrid.CancelCommand and DataGrid.UpdateCommand events, respectively. In these events, you can add the code required to commit changes to the data source and cancel editing (by setting DataGrid.EditItemIndex to -1). Rebind to the data source before returning the page.

Note that you must provide values for the CancelText, EditText, and UpdateText properties (like "Cancel", "Edit", and "Update"). Otherwise, the associated command buttons will not appear in the column when editing is underway.

public class EditCommandColumn : DataGridColumn {
// Public Constructors
   public EditCommandColumn( );
// Public Instance Properties
   public virtual ButtonColumnType ButtonType{set; get; }
   public virtual string CancelText{set; get; }
   public virtual string EditText{set; get; }
   public virtual string UpdateText{set; get; }
// Public Instance Methods
   public override void InitializeCell(TableCell cell, int columnIndex, ListItemType itemType);
              // overrides DataGridColumn
}

Hierarchy

System.Object DataGridColumn(System.Web.UI.IStateManager) EditCommandColumn

    [ Team LiB ] Previous Section Next Section