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. ASP.NET
  4. Dropdownlist items keep duplicating [modified]

Dropdownlist items keep duplicating [modified]

Scheduled Pinned Locked Moved ASP.NET
helpquestion
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.
  • C Offline
    C Offline
    Cyberpulse
    wrote on last edited by
    #1

    I have a dropdownlist whose items are populated dynamically on a button click. I have a gridview being populated with values depending on the value selected in the dropdown list. The problem is that each time the SelectedIndexChanged event is fired the items in the drop down list are duplicated. I cannot use a if(!Page.Postback) block around the dynamic creation of the dropdown's list of items because that occurs on a button click so the page needs to be posted back the first time otherwise the items won't populate. Also, once it duplicates the items if I click on any of the items in the list ... the dropdownlist completely disappears from the page. Any ideas on what I should do ?

    modified on Thursday, October 16, 2008 5:54 PM

    C V 2 Replies Last reply
    0
    • C Cyberpulse

      I have a dropdownlist whose items are populated dynamically on a button click. I have a gridview being populated with values depending on the value selected in the dropdown list. The problem is that each time the SelectedIndexChanged event is fired the items in the drop down list are duplicated. I cannot use a if(!Page.Postback) block around the dynamic creation of the dropdown's list of items because that occurs on a button click so the page needs to be posted back the first time otherwise the items won't populate. Also, once it duplicates the items if I click on any of the items in the list ... the dropdownlist completely disappears from the page. Any ideas on what I should do ?

      modified on Thursday, October 16, 2008 5:54 PM

      C Offline
      C Offline
      Caio Kinzel Filho
      wrote on last edited by
      #2

      can you test if your dropdownlist has items before adding new items? otherwise skip adding... other than that, if AutoPostback of the dropdownlist is set to false, it wont refresh the page

      Intelligence is almost useless for those who have nothing else! Email: caiokf@gmail.com

      1 Reply Last reply
      0
      • C Cyberpulse

        I have a dropdownlist whose items are populated dynamically on a button click. I have a gridview being populated with values depending on the value selected in the dropdown list. The problem is that each time the SelectedIndexChanged event is fired the items in the drop down list are duplicated. I cannot use a if(!Page.Postback) block around the dynamic creation of the dropdown's list of items because that occurs on a button click so the page needs to be posted back the first time otherwise the items won't populate. Also, once it duplicates the items if I click on any of the items in the list ... the dropdownlist completely disappears from the page. Any ideas on what I should do ?

        modified on Thursday, October 16, 2008 5:54 PM

        V Offline
        V Offline
        Venkatesh Mookkan
        wrote on last edited by
        #3

        Cyberpulse wrote:

        I cannot use a if(!Page.Postback) block around the dynamic creation of the dropdown's list of items because that occurs on a button click so the page needs to be posted back the first time otherwise the items won't populate.

        Clear the DropDownList Items everytime using MyDropDown.Items.Clear()

        Castle Rider

        What if I freeze??? Don't forget to breath...

        My: Website | Yahoo Group | Blog Spot

        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