DropDownList previous value

I

Ian Oldbury

i have a dropdownlist box which has autopostback set to true. Does anynone
know if its possible to obtain the value that was in the dropdownlist prior
to the postback?

i could obviously store this value within a hidden field, however i'd like
to do it within the controls properties if possible.

thanks ian
 
C

Cowboy \(Gregory A. Beamer\) [MVP]

There is no built in mechanism for this. If you pull it before it is reset
with the new value, ViewState might be an option, but I would experiment
heavily before releasing this way.

Another option to a hidden field is storing values in ViewState itself.

--
Gregory A. Beamer
MVP; MCP: +I, SE, SD, DBA

************************************************
Think Outside the Box!
************************************************
 
G

Guest

Hi Ian,
I think we can set enableviewstate property for the control, and then
get the dropdownlist values in the post back.. Does it sound ok?
 
K

Karl

I'm a little confused. What do you mean by the value prior to the postback?
Say you have 5 values in your dropdownlist, 1, 2, 3, 4, 5 . When the page
first loads, 1 is selected by default, the user then picks 3, do you want
the value 1 or 3? The user then picks 5 (3 was previously selected), do you
want 3 or 5?

If you want 1 the first time and 3 the 2nd time, there's no way other than
javascript.

If you want 3 the first time and 5 the 2nd, and you aren't getting it from
SelectedValue, my guess is you need to wrap your binding code in an if not
page.ispostback

Karl
 
S

Serdar Kalaycý

This may be your problem since lots of people asks for it.
Do not bind your drop down list on every page load. Just do it for the first
time the page loads using (in C# syntax)
if (!IsPostBack)
bindDDList();
 
C

Cowboy \(Gregory A. Beamer\) [MVP]

This will work as long as you grab before it is changed, by postback this is
gone.

--
Gregory A. Beamer
MVP; MCP: +I, SE, SD, DBA

************************************************
Think Outside the Box!
************************************************
 

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
474,099
Messages
2,570,626
Members
47,237
Latest member
David123

Latest Threads

Top