dropdownlist woes

W

Wee Bubba

i have a dropdownlist consisting of titles (Mr,Mrs,etc.). I use the
text property to store a title and the value properties to store a
default gender code. e.g.

Title Default Gender
---- ----------------
Capt M
Col M
Dr U
Mr M
Mrs F
Ms F

lets say i choose 'Mr'. when i do a postback the dropdownlist reverts
back to 'Capt'. My guess is that it has stored the selectedvalue of
'M' in the ViewState so it restores the first value of M it comes
across in the list after postback! Which is Capt. Wrong! How do I get
around this please?
 
G

Guest

You could do

You can grab the int value of the SelectedIndex property when the user first selects the title, then set the SelectedIndex each time there is a post back.

ie,

// class level
int iTitle;

// on SelectedIndexChanged
iTitle = dropDownList.SelectedIndex;

// any other time
dropDownList.SelectedIndex = iTitle;
 
W

Wee Bubba

is it possible to do without posting back whenever a user makes a new
selection in the dropdownlist?
 

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,431
Messages
2,571,677
Members
48,796
Latest member
Greg L.

Latest Threads

Top