DropDownList Control

G

Guest

I have two DropDownList controls in a web form and I need to test 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;
}
}
}
 
R

Ryan Ternier

I said:
I have two DropDownList controls in a web form and I need to test 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;
}
}
}

So they change a drop down, they click submit, and you want to see which
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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,774
Messages
2,569,598
Members
45,159
Latest member
SweetCalmCBDGummies
Top