|
.net
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
DropDownList Controlcontrol has changed without wrapping it in a SelectedIndexChange Event. How do I go about this issue? I have tried the following which works sort of but the first time I change the selection in one of the DropDownList controls it returns a SelectedValue of null. public string ctrlSelection { get { if(SubList.SelectedValue == null || SubList.SelectedValue == "<-Sub Menu->") { return MainMenuLST.SelectedValue; } else { return SubList.SelectedValue; } } } I am Sam wrote:
Show quoteHide quote > I have two DropDownList controls in a web form and I need to test which So they change a drop down, they click submit, and you want to see which > control has changed without wrapping it in a SelectedIndexChange Event. How > do I go about this issue? I have tried the following which works sort of but > the first time I change the selection in one of the DropDownList controls it > returns a SelectedValue of null. > > public string ctrlSelection > { > get > { > if(SubList.SelectedValue == null || SubList.SelectedValue == "<-Sub > Menu->") > { > > return MainMenuLST.SelectedValue; > } > else > { > return SubList.SelectedValue; > } > } > } one has changed? What if both were changed? DO you have an option in each DDL that states what type of DDL it is ie your: "<-Sub Menu->". If both have something like that, if(SubList.SelectedText == "<-SubMenu->" || MainMenuLST.SelectedText == "<-MainMenu->") { //Nothing Changed } else { if(SubList.SelectedText != "<-SubMenu->" && MainMenuLST.SelectedText == "<-Mainmenu->") { //Sublist changed } else { if(SubList.SelectedText == "<-SubMenu->" && MainMenuLST.SelectedText != "<-Mainmenu->") { //MainMenuChanged } else { if(SubList.SelectedText != "<-SubMenu->" && MainMenuLST.SelectedText != "<-Mainmenu->") { //They Bothchanged } ) ) ) It's long, but simple.
Other interesting topics
Dynamically Adding Controls
Best practice Search with drop down list Updating a DB via SQL is giving me a headache Emailing from app - Help! ASP.NET 2.0 Beta 2 Membership. Help! HttpException (0x80070005): Access denied to 'c:\inetpub' viewstate error link text box to datasource Replace characters in a Dataset? |
|||||||||||||||||||||||