Hi there,
I am trying to add validation controls based on a value in the database.
The idea is to create a questionaire where each question can have a
different type of answer.
I am using a repeater that I have bound to a dataset. The first column in
the dataset holds the question and the second holds a number representing
the type of data I want to validate (1 = number, 2 = date and so on).
The last column holds the answer and is represented by a text box where a
user must enter a value.
Now, for each text box in the repeater, I want to dynamically add a
validation control, like Required, Range etc.
I tried the following solutions:
1. I used OnItemCreated. This gives me access to the repeater item
(including a PlaceHolder control where I could add the Validation control
to) but no access to the actual data so I can't check the type I need to
validate.
2. I used databinding to call a function in my code behind. This function
is passed the type to validate. However, inside that function I can't
access the Repeater, so I can't add controls to it.
Am I missing something? Any ideas on how to get at both the pieces of data
I need (the datatype I am validating from the dataset AND the repeater
control) so I can add controls on the fly?
Cheers and thanks in advance.
Imar