X
xbound
I have two dropdowns: I've added a first item like "Please Select" to each
and each has it own RequiredFieldValidator control which fires if the user
does not select something. The code for the second one looks like this
<aspropDownList ID="ddl2" runat="server" AutoPostBack="true"
AppendDataBoundItems="true" ......
OnSelectedIndexChanged="ddl2_SelectedIndexChanged">
<asp:ListItem Text="Please select" Value="0" />
</aspropDownList>
<asp:RequiredFieldValidator ID="reqddl2" runat="server"
ControlToValidate="ddl2"
Display="Dynamic" ErrorMessage="Name is required"
InitialValue="0">←Required</asp:RequiredFieldValidator>
The second dropdown is populated depending on what's selected in the first
one. In the SelectedIndexChanged event of the first dropdown I've added
this statement [ ddl2.Items.Insert(0, "Please Select") ] because otherwise
that first item won't show up in the second dropdown anymore once the value
in the first dropdown has changed. The problem is that afterward the
validation control for the second dropdown no longer works.
So do I need to validate the second dropdown manually? Any insight
appreciated.
and each has it own RequiredFieldValidator control which fires if the user
does not select something. The code for the second one looks like this
<aspropDownList ID="ddl2" runat="server" AutoPostBack="true"
AppendDataBoundItems="true" ......
OnSelectedIndexChanged="ddl2_SelectedIndexChanged">
<asp:ListItem Text="Please select" Value="0" />
</aspropDownList>
<asp:RequiredFieldValidator ID="reqddl2" runat="server"
ControlToValidate="ddl2"
Display="Dynamic" ErrorMessage="Name is required"
InitialValue="0">←Required</asp:RequiredFieldValidator>
The second dropdown is populated depending on what's selected in the first
one. In the SelectedIndexChanged event of the first dropdown I've added
this statement [ ddl2.Items.Insert(0, "Please Select") ] because otherwise
that first item won't show up in the second dropdown anymore once the value
in the first dropdown has changed. The problem is that afterward the
validation control for the second dropdown no longer works.
So do I need to validate the second dropdown manually? Any insight
appreciated.