why is the selectedvalue of this dropdownlist empty?

B

Bart

Hi,

This code sends back the selectedvalue of a dropdownlist to itself
(postabck).
But the value (dd in the code) is empty.
I must say: it works with EnableViewState="true".

My question is: dropdownlist control doesn't need viewstate for keeping the
value when the ListItems are put declaratively. Why not when the ListItems
are put programmatically?

Thanks
Bart
 
B

bruce barker

if a select is declared declaratively, on postback the item values are
set in oninit by the code the form generates.

if you dynamically update the list, you need to also do it in oninit of
the postback.

if viewstate is enabled, the list is stored in viewstate, and the
control reloades the list in onviewstate load. also the render value is
saved, so the onchange event can be fired.

-- bruce (sqlwork.com)
 
D

David Wier

If you put them in programmatically, in the page load, it reloads every time
the page posts back
You must surround the loading of the ddl with an postback block (if not
page.ispostback then...)
 

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,995
Messages
2,570,226
Members
46,815
Latest member
treekmostly22

Latest Threads

Top