Groups | Blog | Home
all groups > asp.net > july 2003 >

asp.net : DropdownList: How to select by value programaticly?


Northern
7/18/2003 8:53:18 PM
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!
Rajeev Soni
7/19/2003 11:18:32 AM
You should say

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

Rajeev

[quoted text, click to view]

AddThis Social Bookmark Button