Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 212
  • Last Modified:

How to enable/disable a succeeding dropdown list if a value is selected on the first drop down list

Hello experts,
I'm interested in dynamic Drop down list. Let's say i've got three drop down list...
DDL1 - Yes/No
DDL2 - SQLDatasource
DDL3 - SQLDatasource
The condition/s are ...
IF DDL1 selected value is 'Yes' (Postback) DDL2 will be active and DDL3 is disabled.
IF DDL1 value is 'No' (Postback) DDL2 will be disabled and DDL3 is enabled.
Is this possible? Any code suggestion/s or links is much appreciated.
0
jsuanque
Asked:
jsuanque
1 Solution
 
magicdlfCommented:
       <asp:DropDownList ID="DropDownList1" autopostback="true" runat="server" OnSelectedIndexChanged="DropDownList1_SelectedIndexChanged">
 
protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (String.Compare(DropDownList1.SelectedValue, "Yes", true) == 0)
            {
                DropDownList2.Enabled = true;
                DropDownList3.Enabled = false;
            }
            else
            {
                DropDownList2.Enabled = false;
                DropDownList3.Enabled = true;
            }
        }

Open in new window

0
 
jsuanqueAuthor Commented:
Perfect...works like charm. Thanks.
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now