This tutorial applies for Classic ASP, JSP, and PHP but not for ASP.NET. ASP.NET developers should see the ASP.NET tutorials instead.
In unbound mode we populate the combobox in much the same way we would populate an HTML listbox. Here is an example of an unbound combobox with some data:
In this example we have defined two columns labeled "City" and "Population" and filled in some sample values. If you do not want to see the header labels, simply remove the HeaderLabel attribute from the column definitions. You can also specify a Width="100px" (where 100 is your width in pixels) property if you want to explicitly state how wide each column will be. The same applies to the textbox and list.
Adding to the List at Runtime
It's possible to add values to the list at runtime. To do this we use a little bit of JavaScript. You can use this method to create dependant unbound comboboxes.
Let"s begin by using the combo tag above. Next we create a "button" on the page that will perform our action:
Now we create a JavaScript function that will do all the work:
The function we just created doesn't really do anything yet. It just grabs the combobox object so we can work with it.
Next we probably want to clear the list - make it a blank slate:
Now lets add a row of data:
Now here is the complete source code for the function: