Challenge updating dropdown controls from DB

View: New views
1 Messages — Rating Filter:   Alert me  

Challenge updating dropdown controls from DB

by TedByers :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

First, let me make clear that this issue ISN'T populating a dropdown control with items one can select!

The question is one of editing data that has already been stored in a DB.  There are two specific cases.

1) I use JDBC to obtain values from a table that includes string that is one of the values displayed in the listbox (i.e. the dsiplay field not the value field).  I could change this, if need be, to return the value field instead.  The question is, after I have obtained the data from the database, how do I use my string to make the dropdown list selectand display it?  NB: I do NOT want to change the items in the dropdown in this case, just change the item selected based on the data I retrieved from the database so it can be edited.

2) In a second dropdown list, the display and value fields are the same field from the DB, but it will not include  the value returned from the DB.  The logic is that it should show places on a site that are not occupied, and of course the value returned from the DB represents the current location of the object represented in the data returned from the DB for the purpose of editing it.  So the difference in this case from the first is that the value needs to be both added to the list of items in the dropdown control AND selected/shown for the purpose of (possibly) editing it.

Both items 1 and 2 relate to a form for editing data, and the data to be edited is drawn from the DB using JDBC.  The page is almost done, but this is proving to be a bit of a headache.  Anyone have some Motrin for me?  :-(

Is it possible to set up a dropdown box with the appropriate items in the list with nothing being selected or displayed int he textfield?  That is, I have some cases where the textfield for the dropdown ought to be empty until someone explicitly selects one of the items. It would be even better, if this can be done, to be able to do it programmatically (in an event handler for certain other controls: e.g. in cases where items from two dropdowns, containiing fundamentally different items, are mutually exclusive, on a form for editing properties they share).

Thanks

Ted