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. ListBox SelectedIndex problems

ListBox SelectedIndex problems

Scheduled Pinned Locked Moved ASP.NET
helpdatabasequestion
3 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
    tantiboh
    wrote on last edited by
    #1

    I'm building an application where I need the selected index of a ListBox set as AutoPostBack = true to be sent to the backend code for processing. However, on postback, the ListBox always reverts to SelectedIndex = -1, no matter what item I have chosen within the box; as a result, I can't use the selection. EnableViewState IS set to True. Anybody know a solution or workaround for this problem? Thanks for you help!

    J 1 Reply Last reply
    0
    • T tantiboh

      I'm building an application where I need the selected index of a ListBox set as AutoPostBack = true to be sent to the backend code for processing. However, on postback, the ListBox always reverts to SelectedIndex = -1, no matter what item I have chosen within the box; as a result, I can't use the selection. EnableViewState IS set to True. Anybody know a solution or workaround for this problem? Thanks for you help!

      J Offline
      J Offline
      jcrussell
      wrote on last edited by
      #2

      where are you setting the contents of the listbox? When a postback occurs everything in Page_Load is executed first, so make sure that is done in a not Page.IsPostback if statement. that caused a few problems for me when I first started with ASP.NET /jason

      T 1 Reply Last reply
      0
      • J jcrussell

        where are you setting the contents of the listbox? When a postback occurs everything in Page_Load is executed first, so make sure that is done in a not Page.IsPostback if statement. that caused a few problems for me when I first started with ASP.NET /jason

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

        You have put a sudden, joyous end to several hours of misery and frustration. You have my appreciation.

        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