Friday, February 6, 2015

You may need to make sure the KeyValue in DevExpress implementations is not null when attempting to loop through records.

I had to add the null check here...

public static void HideDeleteButton(ref ASPxGridViewTableCommandCellEventArgs e,
      string key)
{
   if (e.CommandColumn.Caption == "Delete")
   {
      if (e.KeyValue != null)
      {
         if (e.KeyValue.ToString() == key)
         {
            e.Cell.Controls.Clear();
         }
      }
   }
}

 
 

...or else when I filtered away all of the rows in a DevExpress grid I would see this error surface:

Object reference not set to an instance of an object

No comments:

Post a Comment