.net DropDownList (DDL) Not showing correct or showing first item everytime

Just a note about something I came across yesterday. I had a DDL that the selecteditem would be incorrect and many times no matter what I chose, the first item would show.

After many hours of trying to figure out what was happening, I cam across this for the SelectedValue Property

https://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.listcontrol.selectedvalue(v=vs.110).aspx

This property returns the Value property of the selected ListItem. The SelectedValue property is commonly used to determine the value of the selected item in the list control. If multiple items are selected, the value of the selected item with the lowest index is returned.

I was adding “true” or “false” to the selectedvalue property. So still needing a t/f I added a count to each resulting in true3 or false5 and then looking for the true/false with InStr.

 

     

Leave a Reply