I have a datalist of textboxes which need to be validated. My problem however, is my requiredfieldvalidators are located outside of my datalist, near the top of the page. When I try setting ControlToValidate in my RFV, I get an error message saying it can't find that control.
If I move my RFV into my datalist, it works fine. Any idea how I can get it to recognize controls in a datalist? Thanks.
You cannot do that. This is because the control names and Ids are generated at runtime based on their parent, datalist and for each row in the datalist. The only workaround I could think of is move the required validator back into the datalist and use Validation summary to display the error messages.
<asp:ValidationSummary runat="server" ID="ValidationSummary1" />