"Cindy" <> wrote in message
news: oups.com...
> Say a the query behind a dropdown list lists various fields -- i.e.,
> ID, State, City. The dropdownlist will display the state and store
> the ID. How do I retrieve the associated city?
Several ways...
1) Unless your DataSet is quite large, you can store it in a client-side
JavaScript array - this would allow you to retrieve the associated city
client-side without any postback / callback...
2) Concatenate the ID and city with a separator charactor and use that as
the value of the dropdown e.g.
1¬London
2¬Paris
3¬New York
Then, when you need to, you can simply split the value on your character
separator e.g.
MyDropDown.SelectedValue.Split('¬')[1];
3) Use AJAX to either look the data up from the database as and when
required or, (maybe) more efficiently, persist the data in Session or
Application cache if it's unlikely to change very often...
I'd go for the third option, personally...
--
Mark Rae
ASP.NET MVP
http://www.markrae.net