Skip to content

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

License

Notifications You must be signed in to change notification settings

DevExpress-Examples/aspxgridview-customize-command-buttons-in-rows

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

26 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

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)