Disable row selection as well as the whole row in DevExpress gridview, based on the cell value in IE and Firefox.

The following tip demonstrates how to enable or disable a row based upon one of its column value
Let us say we want to disable the whole row if OnHand column value of ASPXGridview is 0.

1.by handling ASPXGridview_HtmlRowCreated event of ASPXGridview.

Protected Sub ASPXGridview_HtmlRowCreated(ByVal sender As Object, ByVal e As
DevExpress.Web.ASPxGridView.ASPxGridViewTableRowEventArgs) Handles ASPXGridview.HtmlRowCreated
   If (e.VisibleIndex >= 0) Then
      If (ASPXGridview.GetRowValues(e.VisibleIndex, "OnHand") = 0)Then
         e.Row.Enabled = False
      End If
   End If
End Sub

2. by handling ASPXGridview_HtmlRowPrepared event of ASPXGridview.

Protected Sub ASPXGridview_HtmlRowPrepared(ByVal sender As Object, ByVal e
As DevExpress.Web.ASPxGridView.ASPxGridViewTableRowEventArgs) Handles
ASPXGridview.HtmlRowPrepared
   If (e.VisibleIndex >= 0) Then
      If (ASPXGridview.GetRowValues(e.VisibleIndex, "OnHand") = 0)Then
          e.Row.Enabled = False
      End If
   End If
End Sub

The above two methods work in IE for both GridViewCommandColumn and GridViewDataColumn, but not in Firefox . In case of the latter,  this works for the datacolumn only, the row selection checkbox of DevExpress AspxGridView does not get disabled.

To make it work in  Firefox , we have to handle ASPXGridview_HtmlCommandCellPrepared of ASPXGridview as below.

Protected Sub ASPXGridview_HtmlCommandCellPrepared(ByVal sender As Object, ByVal e As DevExpress.Web.ASPxGridView.ASPxGridViewTableCommandCellEventArgs) Handles ASPXGridview.HtmlCommandCellPrepared
          If e.CommandCellType = DevExpress.Web.ASPxGridView.GridViewTableCommandCellType.Data Then
                 If (ASPXGridview.GetRowValues(e.VisibleIndex, "OnHand") = 0)Then
                          CType(e.Cell.Controls(0), WebControl).Attributes("disabled") = "true"
                End If
         End If
End Sub
150 150 Burnignorance | Where Minds Meet And Sparks Fly!