ListBox not firing SelectedIndexChanged (AutoPostBack=True)

D

danob7

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?
 
B

Brock Allen

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.
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top