|
-
Jun 22nd, 2010, 06:21 AM
#1
Thread Starter
New Member
Gridview validation - almost perfect but not quite
Hi
This is a vb (2008) asp.net site.
I'm using validators in a gridview control. The columns have been converted to templates and, when editing the data the validation works as expected.
However, when the gridview first goes into Edit mode, even if the existing data fails validation, the validators don't highlight the errors UNTIL the data has been manually edited and the field being validated loses its focus. Only then do the validators correctly show the validation errors.
How can I programatically force the validators to check the validation and display their messages when the gridview is first displayed, before the data is edited ?
Note: The validators are warning the user about business rules so it's possible that data from the database can fail validation. Is it possible to programatically disable validation to allow such records to be saved anyway ? Ideally a checkbox or suchlike to disable it.
Cheers - G
-
Jun 22nd, 2010, 06:50 AM
#2
Re: Gridview validation - almost perfect but not quite
Hey,
When the user goes into Edit Mode, they are going into Edit Mode on something that in theory should have already been validated, since it is in the Database, so there shouldn't, by definition, by anything wrong when you first do into edit mode.
Does that make sense?
If you are putting Validators on your page, then you are doing so for a reason, you shouldn't be able to get "around" them.
Gary
-
Jun 22nd, 2010, 09:34 AM
#3
Re: Gridview validation - almost perfect but not quite
How can I programatically force the validators to check the validation and display their messages when the gridview is first displayed, before the data is edited ?
I have never tried the following myself but check out the Validate method and IsValid property. Calling Page.IsValid executes the Validate method of each validator control.
Is it possible to programatically disable validation to allow such records to be saved anyway ? Ideally a checkbox or suchlike to disable it.
If you want to validate everything server side set the EnableClientScript property of each validator control to false. Also set to false the CausesValidation property of the control that submits the changes.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|