ListBox not firing SelectedIndexChanged (AutoPostBack=True)

Discussion in 'ASP .Net Web Controls' started by danob7, Jun 14, 2005.

  1. danob7

    danob7 Guest

    To all .Net gurus out there;

    I have a simple ASP.Net Form, in which I added a ListBox control. I
    populate the content of that ListBox at run time. To save on footprint size,
    I set EnableViewState=False.

    But by doing that, the SelectedIndexChanged stops working (AutoPostBack is
    still = True). Any know of this odd behavior?

    I have a Response.Redirect in my SelectedIndexChanged function, so I have no
    need to keep EnableViewState=True. And since any click would result in a
    redirect, I have no need to "re"load the ListBox on page_load if IsPostBack.

    I know this can be solved by turning EnableViewState = True, but that would
    also make the rendered HTML & view state blob grow at an exponential rate
    when listbox contains hundreds of items...

    Can anyone help?
     
    danob7, Jun 14, 2005
    #1
    1. Advertising

  2. danob7

    Brock Allen Guest

    If you rely upon the SelectedIndex change behavior from the DDL, you must
    enable viewstate. You can get away with repopulating the items in Page_Init,
    but the way the DDL knows if it was changed is it stores the last selected
    index in ViewState. So if you disable it, then it won't work correctly.

    -Brock
    DevelopMentor
    http://staff.develop.com/ballen



    > To all .Net gurus out there;
    >
    > I have a simple ASP.Net Form, in which I added a ListBox control. I
    > populate the content of that ListBox at run time. To save on
    > footprint size, I set EnableViewState=False.
    >
    > But by doing that, the SelectedIndexChanged stops working
    > (AutoPostBack is still = True). Any know of this odd behavior?
    >
    > I have a Response.Redirect in my SelectedIndexChanged function, so I
    > have no need to keep EnableViewState=True. And since any click would
    > result in a redirect, I have no need to "re"load the ListBox on
    > page_load if IsPostBack.
    >
    > I know this can be solved by turning EnableViewState = True, but that
    > would also make the rendered HTML & view state blob grow at an
    > exponential rate when listbox contains hundreds of items...
    >
    > Can anyone help?
    >
     
    Brock Allen, Jun 14, 2005
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Edward
    Replies:
    1
    Views:
    13,526
    Edward
    Feb 4, 2004
  2. =?Utf-8?B?cmRiQGFzbmE=?=
    Replies:
    2
    Views:
    10,187
    Karl Seguin
    Aug 3, 2005
  3. Nathan Sokalski
    Replies:
    0
    Views:
    829
    Nathan Sokalski
    Oct 25, 2007
  4. bdb112
    Replies:
    45
    Views:
    1,348
    jazbees
    Apr 29, 2009
  5. studen771
    Replies:
    0
    Views:
    512
    studen771
    Mar 28, 2007
Loading...

Share This Page