Archive for February, 2010

Oh the ways you can set selected on a dropdownlist!

Tuesday, February 9th, 2010

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.