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
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. Web Development
  3. ASP.NET
  4. Drop down lists

Drop down lists

Scheduled Pinned Locked Moved ASP.NET
databasehelpquestion
3 Posts 3 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.
  • A Offline
    A Offline
    Aptiva Dave
    wrote on last edited by
    #1

    I've got two drop down lists on a page, both connected to a separate sql datasource. The first drop down list is a list of States in the database, the second is a list of political offices that fall under the oversight of the state selected in the first box. If I select a state first, the second drop down list will populate just fine, but if I select another state, the values for the offices of the new state are appended to the bottom of the list after the offices of the first state. Now, I got the appenddatabounditems set to true so that I can have a "Select" statement at the top of the list if there isn't anything selected. Is this the problem, and if so is there a work around for this?

    E T 2 Replies Last reply
    0
    • A Aptiva Dave

      I've got two drop down lists on a page, both connected to a separate sql datasource. The first drop down list is a list of States in the database, the second is a list of political offices that fall under the oversight of the state selected in the first box. If I select a state first, the second drop down list will populate just fine, but if I select another state, the values for the offices of the new state are appended to the bottom of the list after the offices of the first state. Now, I got the appenddatabounditems set to true so that I can have a "Select" statement at the top of the list if there isn't anything selected. Is this the problem, and if so is there a work around for this?

      E Offline
      E Offline
      Ennis Ray Lynch Jr
      wrote on last edited by
      #2

      I usually create a dummy item for the select and then append it to the top of my datasource. Personally I don't like data binding so would rather populate the list with the associated loop instead making it more obvious what is going on and giving this level of control more naturally. Either flavor will work in your situation ... one more suggestion is to use Javascript for the entire procedure instead of postbacks or ajax which really works well for small lists.

      Need software developed? Offering C# development all over the United States, ERL GLOBAL, Inc is the only call you will have to make.
      Happiness in intelligent people is the rarest thing I know. -- Ernest Hemingway
      Most of this sig is for Google, not ego.

      1 Reply Last reply
      0
      • A Aptiva Dave

        I've got two drop down lists on a page, both connected to a separate sql datasource. The first drop down list is a list of States in the database, the second is a list of political offices that fall under the oversight of the state selected in the first box. If I select a state first, the second drop down list will populate just fine, but if I select another state, the values for the offices of the new state are appended to the bottom of the list after the offices of the first state. Now, I got the appenddatabounditems set to true so that I can have a "Select" statement at the top of the list if there isn't anything selected. Is this the problem, and if so is there a work around for this?

        T Offline
        T Offline
        Tarun Dudhatra
        wrote on last edited by
        #3

        Hi First time it comming fine because it's clear so now In the SelectedIndex_Changed event DropDownLost1.Clear(); Code to bind data to DropDownList Then DropDownList1.Items.InsertAt(0,"Select"); I think it will solve your problem Techie From Surat http://techiefromsurat.blogspot.com/

        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