Skip to main content

Command Columns

  • 3 minutes to read

Users can use command columns to manipulate ASPxGridView data. ASPxGridView stores command columns together with its data columns within the ASPxGridView.Columns collection.


A command column is a GridViewCommandColumn class instance. This column supports commands that allow users to switch ASPxGridView to edit mode, update data, delete rows, and more.

A command column allows you to display multiple command items within a cell. Each command item is a single command. A command column supports the following eight command items:

Command Description Property
New Creates a new data row. ASPxGridViewCommandButtonSettings.NewButton
Edit Switches ASPxGridView to an edit mode. ASPxGridViewCommandButtonSettings.EditButton
Delete Deletes the current data row. ASPxGridViewCommandButtonSettings.DeleteButton
Select Selects/deselects data rows. ASPxGridViewCommandButtonSettings.SelectButton, GridViewCommandColumn.ShowSelectCheckbox
Update Saves all changes made to the current data row and switches ASPxGridView to a browse mode. ASPxGridViewCommandButtonSettings.UpdateButton
Cancel Discards any changes made to the current data row and switches ASPxGridView to a browse mode. ASPxGridViewCommandButtonSettings.CancelButton
Clear Clears the filter expression applied to ASPxGridView. ASPxGridViewCommandButtonSettings.ClearFilterButton
Recover Recovers a deleted data row. ASPxGridViewCommandButtonSettings.RecoverButton

A command item is displayed as a link (the default setting). The grid can also display this item as a button or image instead. Use the GridViewCommandColumn.ButtonType property to specify how the command column renders its command items.

Handle the ASPxGridView.CommandButtonInitialize event to initialize individual command buttons.


Users can use a command column’s header to drag this column among visible columns or move it to the Customization Window. The GridViewCommandColumn.AllowDragDrop property enables the drag-and-drop functionality for the command column. If this property is set to Default, the ASPxGridViewBehaviorSettings.AllowDragDrop property defines the column behavior.

Custom Buttons

Command columns can also display custom buttons within command cells or the filter row. You can create your own buttons, and define custom actions for them. Refer to the following topic for an example: How to: Create Custom Command Buttons.

This example shows how to create and initialize a command column with custom command buttons at runtime.

using DevExpress.Web.ASPxGridView;

protected void Page_Load(object sender, EventArgs e) {
    if (!IsPostBack) {
        // Creates and initializes a command column.
        GridViewCommandColumn commandCol = new GridViewCommandColumn("Action");
        commandCol.Name = "Action";
    // Creates a custom command button.
    as GridViewCommandColumn).CustomButtons.Add(CreateCustomButton());

GridViewCommandColumnCustomButton CreateCustomButton() {
    GridViewCommandColumnCustomButton customBtn = new GridViewCommandColumnCustomButton();
    customBtn.ID = "action1";
    customBtn.Text = "Action1";
    customBtn.Visibility = GridViewCustomButtonVisibility.BrowsableRow;
    return customBtn;
// Occurs after a command button has been clicked.
protected void ASPxGridView1_CustomButtonCallback(object sender,
ASPxGridViewCustomButtonCallbackEventArgs e) {
    if (e.ButtonID == "action1") {
        // ...

Handle the ASPxGridView.CustomButtonInitialize event to initialize individual custom command buttons.