I'm creating a data capturing page with drop down lists that are dynamically filled from the database. I have added required field validators but they do not fire, presumably because the validator thinks the first field is selected. Is there way around this issue?
Iv tried the following but I get an error:
Object not set to instance of an object (something like that)
Here is my code (at the the top of the page load event)
if (!IsPostBack)
{
dropList.SelectedItem.Value = "";
}
Thanks!
Without seeing your code, my first guess would be that your required field validations may be missing the IntitialValue field, for example if the initial value of your Drop Down were something like "Please Choose an option" then your required field validator might look like:
<asp:RequiredFieldValidator ID="RequiredFieldValidator5" runat="server" Display="Dynamic" ControlToValidate="ddlProvince" InitialValue="Please Choose an option"></asp:RequiredFieldValidator>
If you have already done this, then I think more information - perhaps some more code, might be helpful in working out what is going on.