Thursday, March 29, 2012

Manually input a value into a drop downlist box

Hi,

I have the follwoing requirment:

I have got a drop down list box populated with names of towns from my database. I want to be able to allow users to manually type in another town name if it does not exist in the list.

If a new town is added, it needs to be added to the database table so that next time the page loads, the new town is in the list.

Does any one know if this is possible using a dropdownlist?

ThanksThis is not possible with the standard DropDownList Controls in Asp.Net. You would need a third party solution, or develop your own. Here is one which is very good:

DbCombo
Another good one which is much easier to use (my biased opinion, I know)...

EasyListBox

Another example

You would take the returned value and insert it into the DB, then databind the list again (the selection does not depend on ViewState)... or alternatively, you could insert the value into the database and then use the AddItem method to add it to the list so you wouldn't have to databind again.

Another decent option for this is Andy Smith'sComboBox control.

0 comments:

Post a Comment