Curtis White
Curtis White

Reputation: 6353

ASP.NET dropdown selected value?

I've an ASP.NET dropdown list and getting selected value by using the .SelectedValue. I also set this value in some cases by assigning to it. I seem to be randomly not getting this value set even when I choose the item from the drop down. Sometimes it works and sometimes it doesn't.

Ideas?

Upvotes: 0

Views: 1451

Answers (2)

earthling
earthling

Reputation: 5264

Make sure you are not re-binding the data on postback before you are able to check the selection.

Also, are you creating listitems and inserting the listitem into multiple lists? If you select one list, it will change the other.

Upvotes: 1

HasanG
HasanG

Reputation: 13161

I you are binding your data at Page_Load make sure you're not re-binding by checking if page is post back.

if(!Page.IsPostBack){ /*bind data here*/ }

Upvotes: 1

Related Questions