This example demonstrates how to hide or disable a command item (button or checkbox) in the grid's command column.
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;
}
}
- Default.aspx (VB: Default.aspx)
- Default.aspx.cs (VB: Default.aspx)
- How to hide a cell value
- How to hide template controls in individual cells
- How to conditionally disable the UpdateButton in client code
- How to create a custom command button with the appearance and action depending on a row state
- How to enable/disable command buttons on the client side
(you will be redirected to DevExpress.com to submit your response)