Thursday, January 29, 2015

doing old school JavaScriptless validation in a DevExpress grid wherein a little red octagon with an exclamation mark inside of it appears by a form field where validation fails

protected void MyGrid_RowValidating(object sender, ASPxDataValidationEventArgs e)
{
   if ((e.NewValues[2] as string).Trim().Length < 42)
   {
      e.Errors[MyGrid.Columns[2]] = "Too short!";
   }
}

 
 

"Too short!" will end up in a tooltip one sees upon mousing over the red octagon. Associate this event with your DevExpress grid like so:

MyGrid.RowValidating += MyGrid_RowValidating;

No comments:

Post a Comment