Home All Groups Group Topic Archive Search About
Author
13 May 2005 10:16 PM
I am Sam
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;
                }
            }
        }

Author
13 May 2005 11:01 PM
Ryan Ternier
I am Sam wrote:
Show quoteHide quote
> 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.

Bookmark and Share