Hiding an ASPXGridView Delete button with HTMLRowCreated vs. CommandButtonInitialize
It's pretty typical in Administration forms to need to hide buttons on certain rows for various reasons. Particularly it is nice to hide the Delete button if in fact the row in question is being used in other places in the app. This is a nice feature to let the user know up front that the row in question is in use, rather than them trying to delete it and getting a foreign key related error after the fact.   For years now in DevExpress ASPxGridView's I have been handling this in the HtmlRowCreated event. And I have been doing it wrong.   Before:   protected  void  gridGiftCodes_HtmlRowCreated ( object  sender,  DevExpress.Web.ASPxGridViewTableRowEventArgs  e)  {   if  (e.RowType  ==  GridViewRowType.Data){     int  commandColumnIndex  =  - 1 ;     //Find the command column    commandColumnIndex  =  e.Row.Cells.Count- 1 ; //assume it's the last visible colum     //Get the command cell for this row    GridViewTableCommandCell  cell  =  e.Row.Cells[commandColumnIndex]  as  Gri...