DropdownList: How to select by value programaticly?

  • Thread starter Thread starter Northern
  • Start date Start date
N

Northern

I have an ASP DropdownList populated. What I want is to
select a new item, in my code, by set a datavale to
dropdownlist's selectedItem.Value property. I did the
following:

MyDropdown.SelectedItem.Value = "value 1"

Even though the "value 1" is in the dropdownlist's data
value collection, the dropdown's datatext doesn't change.

What am I doing wrong here? How should I do this?

Please help!
 
You should say

MyDropdown.SelectedIndex = <Index of the Item you want to select.>

Rajeev
 
Glad to hear that it worked for you!

Ken

Thank you so much Ken. That's exactly what I need.
You are the MVP!

Thank a million!
 
Back
Top