Skip to main content
Tab

GridViewCommandColumnCustomButton Class

Represents a custom command button.

Namespace: DevExpress.Web

Assembly: DevExpress.Web.v24.2.dll

Declaration

public class GridViewCommandColumnCustomButton :
    GridCustomCommandButton

The following members return GridViewCommandColumnCustomButton objects:

Remarks

Command columns can display custom buttons. These buttons are stored within a column’s GridViewCommandColumn.CustomButtons collection.

CustomButtons

Custom buttons are represented by the GridViewCommandColumnCustomButton objects. The button’s text and image are specified by the GridViewCommandColumnButton.Text and GridViewCommandColumnButton.Image properties, respectively. A button’s identifier can be specified by the GridCustomCommandButton.ID property.

To learn more, see How to: Create Custom Command Buttons.

Example

  • Creates a command column with a custom command button in design time.

    <dx:ASPxGridView ID="ASPxGridView1" runat="server" ClientInstanceName="gridView">
        <ClientSideEvents CustomButtonClick="grid_CustomButtonClick" />  
        <Columns>  
            <dx:GridViewCommandColumn VisibleIndex="0" Width="100px">  
                <CustomButtons>  
                    <dx:GridViewCommandColumnCustomButton Text="Show New Window" ID="ShowNewWindow">  
                    </dx:GridViewCommandColumnCustomButton>  
                </CustomButtons>  
            </dx:GridViewCommandColumn>  
            ...
        </Columns>  
    </dx:ASPxGridView>
    
  • Creates and initializes 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";
            ASPxGridView1.Columns.Add(commandCol);
        }
        // Creates a custom command button.
        (ASPxGridView1.Columns["Action"] 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") {
            // ...
        }
    }
    
See Also