Click here to Skip to main content
15,867,943 members
Please Sign up or sign in to vote.
3.00/5 (2 votes)
See more:
Hello,

I have a requirement in which I am binding some items from a list to a dropdownlist.

After I have accomplished this ,now I want to Display a textbox where a user can enter his comments as per the value selected by him from the dropdownlist.

Now after the user has selected the particular dropdownlist value I want that value to
be non editable so that the user cannot select a given value more than once in a dropdownlist.

How to restrict the user to select a given dropdownlist value once?


ddldropPPO.Items.Add(testdef.PPO1.ToString());  //Items fetched from a list
string PPO = ddldropPPO.SelectedItem.Text;
TextBox txtreason = new TextBox();
string reason = txtreason.Text;
Posted
Comments
Timberbird 30-May-11 2:46am    
Could you please clarify - do you want to restrict user from selecting this item in DropDownList (removing it from the list completely, for example) or this item should be selectable, but when selected, comment TextBox shouldn't be editable?
Kaira_29 30-May-11 3:13am    
I do not want to remove the selected item from the DropDownList but I want to prevent the user from clicking it twice.So when he clicks on to the dropdown my TextBox should not be editable with a Message gettting displayed

1 solution

The simplest way would be to remove the value from the collection and rebind after the user has selected that value.
 
Share this answer
 
Comments
FJD.DEETLEFS 30-May-11 5:43am    
Simplest and most obivious solution.No need to overcomplicate a simple task.
Abhinav S 30-May-11 8:05am    
Thank you.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900