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. SelectedIndexChanged not firing?

SelectedIndexChanged not firing?

Scheduled Pinned Locked Moved ASP.NET
helpcsharpasp-netdata-structuresquestion
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.
  • E Offline
    E Offline
    Evan Schultz
    wrote on last edited by
    #1

    (note: I am pretty new to ASP.NET, had little to no exp with it prior to starting this job a week ago) This has me scratching my head a little, as the other day at the end of work - this code worked for me, did what I wanted it to do. Get into the office today (working on xmas eve, yay!), do a quick compile to refresh myself to where I left off ... and - it no longer works. I am progmatically creating some web controls on the page, its an array of them - setting them up based on some attributes set in my tag. in the Page_Load function, I have code that sets up some headers, binds the datagrid, and then calls SetupFilters(); which then loops though alist of filters to be created, and spits them out. In the setup filter, i have ddList[x].SelectedIndexChanged += new EventHandler(SearchDropDown); // other setup stuff for the filter, populate it, etc this.Controls.Add(ddList[x]); Last night, this was working - this morning, its not, and nothing has changed between now and then. After scratching my head for a bit, I tried moving the call to SetupFilter() from Page_Load to OnInit - this now works. Problem solved, I think? But, I am not sure - why it stopped working? - was having that in page_load wrong in the first place? - why would it start working in OnInit but not page_load? I dont like doing 'blind fixs' where they seem to work for the time being, and not understand WHY the fix worked, as I'm sure it'll bite me in the ass in a few weeks.

    M 1 Reply Last reply
    0
    • E Evan Schultz

      (note: I am pretty new to ASP.NET, had little to no exp with it prior to starting this job a week ago) This has me scratching my head a little, as the other day at the end of work - this code worked for me, did what I wanted it to do. Get into the office today (working on xmas eve, yay!), do a quick compile to refresh myself to where I left off ... and - it no longer works. I am progmatically creating some web controls on the page, its an array of them - setting them up based on some attributes set in my tag. in the Page_Load function, I have code that sets up some headers, binds the datagrid, and then calls SetupFilters(); which then loops though alist of filters to be created, and spits them out. In the setup filter, i have ddList[x].SelectedIndexChanged += new EventHandler(SearchDropDown); // other setup stuff for the filter, populate it, etc this.Controls.Add(ddList[x]); Last night, this was working - this morning, its not, and nothing has changed between now and then. After scratching my head for a bit, I tried moving the call to SetupFilter() from Page_Load to OnInit - this now works. Problem solved, I think? But, I am not sure - why it stopped working? - was having that in page_load wrong in the first place? - why would it start working in OnInit but not page_load? I dont like doing 'blind fixs' where they seem to work for the time being, and not understand WHY the fix worked, as I'm sure it'll bite me in the ass in a few weeks.

      M Offline
      M Offline
      minhpc_bk
      wrote on last edited by
      #2

      Hi there, In my opinion, there might be some reasons as to why the SelectedIndexChanged event does not fire. In the 'Process postback data' phase of the Control Execution Lifecycle, the LoadPostData method will be running. This method basically does a comparison between the current selected item with the posted value. Depending on the returned value of the method, the SelectedIndexChanged will be raised or not in the next phase ('Send postback change notifications'). So I think that there may be no data at all in the Items of the control when the LoadPostData is running, and the event is not raised. Another reason might be when the SelectedIndexChanged event fires in the 'Send postback change notifications' phase, there is no handler registered for this event by that time, so you might think that the event does not fire. For more information, I'd recommend you to read some documents below: Control Execution Lifecycle[^] Processing Postback Data[^] Adding Controls to a Web Forms Page Programmatically[^]

      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