473,396 Members | 2,033 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

check box should disable on selection of dropdown list box.

Hi,
I am new in C# ,i have one problem ,i want to disable the check box when we select any particilar item from dropdown list.suppose i have five item in dropdown list box(A,B,C,D,E) and two checkbox, checkbox1 , checkbox2 i want when i select B checkbox1 should be disable.Please help regarding this problem ASAP.

Regards,
Shailesh Kumar
Jun 14 '07 #1
2 2368
nateraaaa
663 Expert 512MB
Hi,
I am new in C# ,i have one problem ,i want to disable the check box when we select any particilar item from dropdown list.suppose i have five item in dropdown list box(A,B,C,D,E) and two checkbox, checkbox1 , checkbox2 i want when i select B checkbox1 should be disable.Please help regarding this problem ASAP.

Regards,
Shailesh Kumar
In the SelectedIndexChanged event of your dropdownlist add code that will disable your checkboxes based on the current index selected in your dropdownlist. You may want to add a switch statement so that you can handle each index selected in this event.

Expand|Select|Wrap|Line Numbers
  1. public void nameofdropdownlist_SelectedIndexChanged(object sender, System.EventArgs e)
  2. {
  3.   switch(nameofdropdownlist.SelectedItem.Text.ToString())
  4.   {
  5.      case "A":
  6.        checkbox1.Enabled = true;
  7.        checkbox2.Enabled = true;
  8.        break;
  9.     case "B":
  10.        checkbox1.Enabled = false;
  11.        checkbox2.Enabled = true;
  12.        break;
  13.     default:
  14.        checkbox1.Enabled = true;
  15.        checkbox2.Enabled = true;
  16.        break;
//create a case statement for each item in your dropdownlist that you would like to change the Enabled property of your checkboxes
//if the SelectedItem of your dropdownlist does not exists in a case statement then the code will run the default and set the checkboxes to whatever you would like them to be.

This should get you on the right track.

Nathan

}
}
Jun 14 '07 #2
TRScheel
638 Expert 512MB
What nathan said, and make sure the dropdown box posts back, otherwise I doubt the change will take hold.
Jun 14 '07 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

10
by: JL | last post by:
Does anyone have any ideas on this please? I don't know how to evaluate the no-blank selections against each other from a form as follows: . I have a form with 6 dropdown fields, each...
1
by: Christopher D. Wiederspan | last post by:
I'm wondering if there's a way to use javascript to disable a ASP.NET web page before it starts to postback. Specifically, here's what I'm running into. I've got a webform that has an autopostback...
6
by: Mark | last post by:
I have two dropdown lists. Both have autopostback set to true. In both dropdowns, when you select an item from the list, it redirects to the Value property of the dropdown. Nothing fancy. ...
4
by: Paul | last post by:
I have a dropdown list box and a button on a web form, the autopost back is false for the dropdown list box and button. When the button is pushed the selection in the dropdownlist box is lost,...
10
by: Geoff | last post by:
Is there any way to change the enabled property of a dropdownlist without a postback, depending on the selection in another dropdownlist? Select Case ddlReport.SelectedValue Case "Profit" ...
1
by: tkdunn | last post by:
I made a dropdown list that populates based upon a previous selection in a drop down list, so i can filter out what is in the drop down list. some of the selections from the first dropdown list do...
5
by: =?Utf-8?B?QnJlbmRlbiBCaXhsZXI=?= | last post by:
Hello. I am reading a value from a table and trying to determine if that value exists in a list of values associated with a dropdownlist. If so, I select the value, otherwise, I don't. I haven't...
3
by: thirish | last post by:
Hi, I have jsp page, on jsp page, The data is displaying from xml island. the Requriement is i have optional button and dropdown in each row. if user check the option button in second row then...
5
by: plumba | last post by:
Hi all. I have two drop down menus, the first a list of Departments, the second a list of Sections. Each Department has a set of Setions, so the Sections dropdown contains complete list of all...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.