Wednesday, March 28, 2012

Validating controls within GridView

I'm trying to validate controls within a GridView. I can get it working but the control is still causing a postback, which is something I don't want when a validation error occurs - in fact, I want the validation control to prevent a null value from being stored on the db.

Is there a way of disabling postback when a validation error occurs?

Default behavior is to avoid postback by using client-side validation. Unless this behavior is somehow changed either by some setting or due to browser compatibility, the postback should not occur upon validation error. Also check to make sure the command source (button or linkbutton) has the CausesValidation set to true (which I believe is default value). I've verified this behavior using a simple GridView.

No comments:

Post a Comment