dynamically adding validators
<p>In my case I would like to dynamically add validators to my control based on given logic. For each control I first check something in my DB and if it goes aout that field is required I would like to add requiredField to that control. I firt iterate through each control and if its required I add attribute required="true".</p>

<p>I added this code but it doens work I mean nothing happens, none validation is being made.</p>

<pre><code>if(gc.Attributes["controlid"] != null)
    {
        RequiredFieldValidator validator = new RequiredFieldValidator();
        validator.ControlToValidate = gc.Attributes["controlid"];
        validator.ErrorMessage = gc.Attributes["errormessage"];
        this.Controls.Add(validator);
    }
</code></pre>

<p>Thanks for any suggestions.</p>
