HowTo Use RegularExprValidator and DataList

H

HelpForNewbie

I have a datalist of parameters that I need to validate. Each parameter
(row) can represent a different data type. Some are dates, some are patterns
as \d{2}[-]\d{2}. All are kept in the same table as varchar columns.

How I would like to do is to add a new column to this table that contains
the regular expression valiadation string in order to validate the associated
value. For Example:

ParmName ParmValue RegExp
StartDate 10/01/2004 [012]?\d\/[0123]?\d\/[0]\d
ContactTel 999-999-4444 \d{3}[-]\d{3}[-]\d{4}
....
....

Is is possible to have the Reg Validator within the EditItem template so row
each contains the specific reg expr for validation? Could the RegExp column
be feed into the ValidationExpression property for each row?

Thank you,

Jim
 
T

Teemu Keiski

Hi,

yes it should be. Just place the RegExpValidator declaration into separate
column on the table (and set the ControlToValidate to point the control,
which of course needs to be a input control, you want to validate). You can
in ItemDataBound event of the DataList access the validator with per-row
idea and apply suitable validation expression.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,011
Latest member
AjaUqq1950

Latest Threads

Top