If you need to validate some user input against a set of allowed values, you can use the
RegularExpressionValidator
by setting its
ValidationExpression
as follows:
EUR|USD|AUD|CHF
The '|' symbol delimits the set of allowed values in a regular expression.
If you need to load the list of allowed values from a database, config file or other source, you can do so, and simply set the
ValidationExpression
property of the
RegularExpressionValidator
at runtime.
Dim currencyDAL As New CurrencyDAL()
Dim currencies As List(Of String) = currencyDAL.SelectAll()
Dim expression As String = String.Join("|", currencies.ToArray)
currencyValidator.ValidationExpression = expression
Simple.