0

I would like to ask, how to disable the value in drop down menu after being selected? I mean, let says if when User A select value B in drop down list, B is not available to be selected anymore to any user. How to do that?

1 Answer 1

1

you should be able to have an event handler for that dropdown menu and from there you have many options! it depends on what you mean anyother user cant select it, if you mean only within that session or untill the whole process or never again?

DropDownList DropDownList1 = new DropDownList();
DropDownList1.SelectedIndexChanged += new EventHandle(DropDownList1_SelectedIndexChanged);

so the first line you have your dropdown list and then the second part is creating an event for your dropdown list. That event fires when the item you select has changed from the origional and it will trigger this:

    private void DropDownList1_SelectedIndexChanged(object sender, EventArgs e)
    {
        //put your code here ;)
    }

You can save to the database the values that have been selected and populate the dropdownbox onloading of the page? thats if its over a long period of time or forever.

If its only for the session than you can create an array and store the values that have been selected. Once you store it you need to repopulate your list to only include the options that havent been selected.

the above method you can also use if you want to keep the values in but not allow the values to be selected but you would need to do some validation against the array to check if its currently selected == arraylist values.

So there are many options for you to do what you want to do but you need to be more specific in what you want to do, over how long you want to do it :)

hope this helps :)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.