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. General Programming
  3. C#
  4. DropDownList/ListItem Problem

DropDownList/ListItem Problem

Scheduled Pinned Locked Moved C#
databasehelptutorial
4 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.
  • T Offline
    T Offline
    TheMajorRager
    wrote on last edited by
    #1

    I am working on this project, when I add items to a drop down list using a list item it wont into the event handler on selectedindexchanged. However, use the other definition for the dropdown to add in items via a string, it actually goes into the event handler on selected index changed, for example when I do this: ListItem item = new ListItem("One","1"); DropDownList1 = new DropDownList(); DropDownList1.Items.Add(item); it will add it in, but when I select something different it wont go into the event handler, but when I do this: DropDownList1 = new DropDownList(); DropDownList1.Items.Add("One"); it will go into the event handler. I dont understand why this is.

    G T 2 Replies Last reply
    0
    • T TheMajorRager

      I am working on this project, when I add items to a drop down list using a list item it wont into the event handler on selectedindexchanged. However, use the other definition for the dropdown to add in items via a string, it actually goes into the event handler on selected index changed, for example when I do this: ListItem item = new ListItem("One","1"); DropDownList1 = new DropDownList(); DropDownList1.Items.Add(item); it will add it in, but when I select something different it wont go into the event handler, but when I do this: DropDownList1 = new DropDownList(); DropDownList1.Items.Add("One"); it will go into the event handler. I dont understand why this is.

      G Offline
      G Offline
      George L Jackson
      wrote on last edited by
      #2

      Make sure "AutoPostBack" is set to "true" and the "SelectedIndexChange" event is actually pointing to your event handler before testing your application. Sometimes when you move or modify your control, it resets everything back to its default settings. Also, unless you are creating a DropDownList dynamically, don't initialize it. This action will also reset it back to its original default settings.

      T 1 Reply Last reply
      0
      • G George L Jackson

        Make sure "AutoPostBack" is set to "true" and the "SelectedIndexChange" event is actually pointing to your event handler before testing your application. Sometimes when you move or modify your control, it resets everything back to its default settings. Also, unless you are creating a DropDownList dynamically, don't initialize it. This action will also reset it back to its original default settings.

        T Offline
        T Offline
        TheMajorRager
        wrote on last edited by
        #3

        Hi George, thanks for replying to me. I did all of that already, they are dynamic, I don't understand why it wont work. Have you tried it both ways, I dont know if it's teh IDE or what. Im using .NET 2003 though.

        1 Reply Last reply
        0
        • T TheMajorRager

          I am working on this project, when I add items to a drop down list using a list item it wont into the event handler on selectedindexchanged. However, use the other definition for the dropdown to add in items via a string, it actually goes into the event handler on selected index changed, for example when I do this: ListItem item = new ListItem("One","1"); DropDownList1 = new DropDownList(); DropDownList1.Items.Add(item); it will add it in, but when I select something different it wont go into the event handler, but when I do this: DropDownList1 = new DropDownList(); DropDownList1.Items.Add("One"); it will go into the event handler. I dont understand why this is.

          T Offline
          T Offline
          TheMajorRager
          wrote on last edited by
          #4

          Anyways, I was able to work around it, I had to basically re-engineer everything I did, and use the second definition using strings instead of ListItems in the DropDownList. Thanks for everything. Sincerely, The Major Rager

          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