Skip to content

About

Hide or disable a command item (button or checkbox) in the grid's command column.

Topics

Resources

Stars

0 stars

Watchers

54 watching

Forks

Latest commit

 

History

85 Commits

Folders and files

Repository files navigation

Grid View for ASP.NET Web Forms - How to customize command buttons in individual rows

This example demonstrates how to hide or disable a command item (button or checkbox) in the grid's command column.

A grid with command buttons

To do this, handle the CommandButtonInitialize event. This event is raised for each built-in command button. In the event handler, use the e.ButtonType property to determine the button type. Then, depending on the ButtonType property value, use the e.Visible to hide the button or use the e.Enabled property to disable the checkbox.

protected void ASPxGridView1_CommandButtonInitialize(object sender, DevExpress.Web.ASPxGridViewCommandButtonEventArgs e) {
    bool isOddRow = e.VisibleIndex % 2 == 0;
    if(isOddRow) {  // some condition
        // hide the Edit button
        if(e.ButtonType == DevExpress.Web.ColumnCommandButtonType.Edit)
            e.Visible = false;

        // disable the selection checkbox
        if(e.ButtonType == DevExpress.Web.ColumnCommandButtonType.SelectCheckbox)
            e.Enabled = false;
    }
}

Files to Look At

Documentation

More Examples

Does This Example Address Your Development Requirements/Objectives?

(you will be redirected to DevExpress.com to submit your response)

About

Hide or disable a command item (button or checkbox) in the grid's command column.

Topics

Resources

Stars

0 stars

Watchers

54 watching

Forks

Used by

Contributors

Languages