Jump to content

GetControlById in C#


RightPilot

Recommended Posts

From the sever side, I want to be able to select the value in a drop down. The problem is that the dropdown is one of 6. One of these 6 dropdowns is selected based on another dropdown's selection. i.eID=DropDown1 Options=A, B, C, D, E, Fwill then cause one of the following to have the ID=DropDownA Options=...ID=DropDownB Options=...ID=DropDownC Options=<appropriate value selected>ID=DropDownD Options=...ID=DropDownE Options=...ID=DropDownF Options=...So essentially, I will have:"DropDown" + DropDown1.SelectedValueas a string representing the ID of the dropdown which I then want to search for in the page...What method/procedure do I use to search for the right control in the page?Right P.

Link to comment
Share on other sites

Can you use a switch?

DropDownList subList;switch(DropDown1.SelectedValue){	case "A":		subList = DropDownA;		break;	case "B":		subList = DropDownB;		break;	case "C":		subList = DropDownC;		break;	// more options...}string optionValue = subList.SelectedValue;

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...