Good day!
I have a simple code here:
<asp:DropDownList ID="ddlNumber" runat="server">
<asp:ListItem></asp:ListItem>
<asp:ListItem>1</asp:ListItem>
<asp:ListItem>2</asp:ListItem>
<asp:ListItem>3</asp:ListItem>
</asp:DropDownList>
<asp:DropDownList ID="ddlText" runat="server">
<asp:ListItem></asp:ListItem>
<asp:ListItem>a</asp:ListItem>
<asp:ListItem>b</asp:ListItem>
<asp:ListItem>c</asp:ListItem>
</asp:DropDownList>
What I wanted to do is whenever a dropdown is not empty, the other dropdown is disabled.
The code I have tried so far isn't working:
if (ddlNumber.SelectedValue == "" && ddlText.SelectedValue == "")
{
ddlNumber.Enabled = true;
ddlText.Enabled = true;
}
else if (ddlNumber.SelectedValue != "")
{
ddlText.Enabled = false;
}
else if (ddlText.SelectedValue != "")
{
ddlNumber.Enabled = false;
}
Any help would be much appreciated. Thank you.