Oh the ways you can set selected on a dropdownlist!

I recently ran into this problem that seemed really odd. This is the .net world and I am using an item template. On itemdatabound I set a drop downlist’s selected item like this:

somedropdownlist.Items.FindByText("someText").Selected = True

I thought this should have worked. It did not. When the control was rendered the item I choose was not selected. So I thought that this could be a life-cycle thing. I tried:

somedropdownlist.SelectedValue = "Some Value"

that worked. Why? I don’t get it.

Tags: , ,

Leave a Reply

*
To prove you're a person (not a spam script), type the security word shown in the picture. Click on the picture to hear an audio file of the word.
Click to hear an audio file of the anti-spam word