Need to Disable Dropdown Box ASP.NET C# 2.0

I need to be able to disable multiple dropdowns when either dropdown has a value first.  This is for a reporting screen.  Example - if a user selects state, city and country needs to be disable
jedwards_2Asked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Anurag ThakurTechnical ManagerCommented:
set the autopostback event for all the dropdowns
set the OnSelectedIndexChanged changed property for each dropdown and in that function for the event check if a value eg for state is set then disable the other 2 dropdowns and vice versa
0
jedwards_2Author Commented:
i thought i did that.  can you provide any examples?
0
Anurag ThakurTechnical ManagerCommented:
i am assuming that the data in the drop down list has been bound in the page load event
there is a "Select" option in all the drop downs  and the value is -1
<asp:DropDownList ID="ddStates" runat="server" OnSelectedIndexChanged="ddStates_SelectedIndexChanged" AutoPostBack="True" Width="150px"></asp:DropDownList>
<asp:DropDownList ID="ddCounties" runat="server" Width="150px" OnSelectedIndexChanged="ddCounties_SelectedIndexChanged" AutoPostBack="True"></asp:DropDownList>
 
 
C# code
	protected void ddStates_SelectedIndexChanged (object sender, EventArgs e)
	{
		if (ddStates.SelectedValue != "-1")
		{
			ddCountries.Enabled = false;
		}
		else
		{
			ddCountries.Enabled = true;
		}
	}
 
	protected void ddCounties_SelectedIndexChanged (object sender, EventArgs e)
	{
		if (ddCountries.SelectedValue != "-1")
		{
			ddStates.Enabled = false;
		}
		else
		{
			ddStates.Enabled = true;
		}
	}

Open in new window

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
C#

From novice to tech pro — start learning today.