I am Sam wrote:
I have two DropDownList controls in a web form and I need to test which
control has changed without wrapping it in a SelectedIndexCh ange 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.Sele ctedValue == null || SubList.Selecte dValue == "<-Sub
Menu->")
{
return MainMenuLST.Sel ectedValue;
}
else
{
return SubList.Selecte dValue;
}
}
}
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.Sele ctedText == "<-SubMenu->" || MainMenuLST.Sel ectedText ==
"<-MainMenu->")
{
//Nothing Changed
}
else
{
if(SubList.Sele ctedText != "<-SubMenu->" &&
MainMenuLST.Sel ectedText == "<-Mainmenu->")
{
//Sublist changed
}
else
{
if(SubList.Sele ctedText == "<-SubMenu->" &&
MainMenuLST.Sel ectedText != "<-Mainmenu->")
{
//MainMenuChanged
}
else
{
if(SubList.Sele ctedText != "<-SubMenu->" &&
MainMenuLST.Sel ectedText != "<-Mainmenu->")
{
//They Bothchanged
}
)
)
)
It's long, but simple.