Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. Adding Entries to DropDownList Box

Adding Entries to DropDownList Box

Scheduled Pinned Locked Moved Web Development
questiondatabasehelp
2 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • P Offline
    P Offline
    Pradhip
    wrote on last edited by
    #1

    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 ??

    P 1 Reply Last reply
    0
    • P Pradhip

      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 ??

      P Offline
      P Offline
      Paul Watson
      wrote on last edited by
      #2

      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 Africa

      Ray Cassick wrote:
      Well I am not female, not gay and I am not Paul Watson

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups