[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

Need to Disable Dropdown Box  ASP.NET C# 2.0

Posted on 2008-11-11
3
Medium Priority
?
874 Views
Last Modified: 2012-05-05
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
0
Comment
Question by:jedwards_2
  • 2
3 Comments
 
LVL 26

Expert Comment

by:Anurag Thakur
ID: 22933214
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
 

Author Comment

by:jedwards_2
ID: 22933274
i thought i did that.  can you provide any examples?
0
 
LVL 26

Accepted Solution

by:
Anurag Thakur earned 1500 total points
ID: 22936239
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

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Just a quick little trick I learned recently.  Now that I'm using jQuery with abandon in my asp.net applications, I have grown tired of the following syntax:      (CODE) I suppose it just offends my sense of decency to put inline VBScript on a…
A quick way to get a menu to work on our website, is using the Menu control and assign it to a web.sitemap using SiteMapDataSource. Example of web.sitemap file: (CODE) Sample code to add to the page menu: (CODE) Running the application, we wi…
Please read the paragraph below before following the instructions in the video — there are important caveats in the paragraph that I did not mention in the video. If your PaperPort 12 or PaperPort 14 is failing to start, or crashing, or hanging, …
In a question here at Experts Exchange (https://www.experts-exchange.com/questions/29062564/Adobe-acrobat-reader-DC.html), a member asked how to create a signature in Adobe Acrobat Reader DC (the free Reader product, not the paid, full Acrobat produ…
Suggested Courses

872 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question