Adding Entries to DropDownList Box
-
Hi All: I have a peculiar Challenge and need a work around.There is a form that my application uses which has a drop down list being populated at run time.And there can be a case when there is no data to populate it. Apart from the data being populated i want the dropdownlist to have the option "Select one by clicking" as the default selected option in this listbox.I have managed to do it by the commands txt_listbox.items.add and then selected It using txt_listbox.items.findbytext("---").selected=true but then the challenge is this option though gets selected is the last item on my dropdown listbox after all the data from the datatbase..But i want it to be the first..How do i do that. If i try adding this entry and then populating from the database the database entries wipe out this entry or i get some nasty errors. Any help is greatly appreciated.. Regards Pradhip.S If a Building is Completed then why do they call it BUILDING ??
-
Hi All: I have a peculiar Challenge and need a work around.There is a form that my application uses which has a drop down list being populated at run time.And there can be a case when there is no data to populate it. Apart from the data being populated i want the dropdownlist to have the option "Select one by clicking" as the default selected option in this listbox.I have managed to do it by the commands txt_listbox.items.add and then selected It using txt_listbox.items.findbytext("---").selected=true but then the challenge is this option though gets selected is the last item on my dropdown listbox after all the data from the datatbase..But i want it to be the first..How do i do that. If i try adding this entry and then populating from the database the database entries wipe out this entry or i get some nasty errors. Any help is greatly appreciated.. Regards Pradhip.S If a Building is Completed then why do they call it BUILDING ??
Pradhip wrote: If i try adding this entry and then populating from the database the database entries wipe out this entry or i get some nasty errors. (I assume you are doing this in ASP because you are in the web dev forum, not the ASP.NET forum. I also assume this is not a Windows app you are talking about...) Ok I do not have access to your code so I am just going to give you a sample of how we do it:
<select name="selSample" id="selSample">
<option value="na" selected="true">Select one by clicking
<%
Do Until rs.EOF
Response.Write("<option value=""" & rs("id") & """>" & rs("Title") & "</option>")
rs.MoveNext
Loop
%>
</select>As you can see first the
<select>
is created, then the default/selected item created. Then it loops through all the items in the recordset outputting the neccesary<option>
elements.Paul Watson
Bluegrass
Cape Town, South AfricaRay Cassick wrote:
Well I am not female, not gay and I am not Paul Watson