Dropdownlist.SelectedValue ISSUE

S

Sudhir

Hi,
I have a dropdownlist, which I am creating during runtime. I am then
populating it dynamically. Depeding on a condition, I am changing the
selected value. After this I am adding the dropdown to a panel. But
the dropdown is not showing the new selected value when the page
loads. Does anyone had similar problems? Any help is greatly
appreciated.

Thanks,
Sudhir
 
S

Scott Mitchell [MVP]

I have a dropdownlist, which I am creating during runtime. I am then
populating it dynamically. Depeding on a condition, I am changing the
selected value. After this I am adding the dropdown to a panel. But
the dropdown is not showing the new selected value when the page
loads. Does anyone had similar problems? Any help is greatly
appreciated.


Sudhir, try doing something like:

Dim lb as ListItem = myDDL.Items.FindByValue(value to look for)
If Not lb Is Nothing Then lb.Selected = True


See if that doesn't do the trick... :)

--

Scott Mitchell
(e-mail address removed)
http://www.4GuysFromRolla.com
http://www.ASPFAQs.com
http://www.ASPMessageboard.com

* When you think ASP, think 4GuysFromRolla.com!
 

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,579
Members
45,053
Latest member
BrodieSola

Latest Threads

Top