CustomValidator - GridView

jazzmik

New member
Joined
Jul 20, 2006
Messages
1
Programming Experience
5-10
Hi,
Lets see if i can make sense with this question:

I have a GridView set up. There are 2 columns that use CustomValidator.
The values in these 2 columns need to be <= 999.99 AND column1 (min) needs to be < column2 (max).

Column 1 uses: OnServerValidate="cvLSHOPFormLengthMin_ServerValidate
Column 2 uses: OnServerValidate="cvLSHOPFormLengthMax_ServerValidate

I have 2 problems trying to validate.

1. The validation will allow a user to enter something like 9,9.99 ... it will return IsValid and populate the column with 99.99. It doesn't allow any other special characters, so that's good. Would like to not allow a "," also... if that's possible.

2. I need to make sure that column 1 is LESS THAN column 2. How can I validate both columns comparing them to one another? I would think that each CustomValidator acts independently of one another. Is that so?

Any help is appreciated. Thanks in advance.

Here is the underlying VB code:

VB.NET:
Protected Sub cvLSHOPFormLengthMin_ServerValidate(ByVal source As Object, ByVal args As System.Web.UI.WebControls.ServerValidateEventArgs)
 
If gvClientServiceCrossReference.Columns(9).Visible = True And IsInvalidNumber(args.Value, 999.99, 2) Then
   args.IsValid = False
   blnHasValidationErrors = True
Else
    args.IsValid = True
End If

End Sub
 
Protected Sub cvLSHOPFormLengthMax_ServerValidate(ByVal source As Object, ByVal args As System.Web.UI.WebControls.ServerValidateEventArgs)

If gvClientServiceCrossReference.Columns(10).Visible = True And IsInvalidNumber(args.Value, 999.99, 2) Then
   args.IsValid = False
   blnHasValidationErrors = True
Else
   args.IsValid = True
End If

End Sub
 
Back
Top