By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
440,159 Members | 1,880 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 440,159 IT Pros & Developers. It's quick & easy.

DropDownList Behaviour - why is it so?

P: n/a
All

I have a .Net 2003 webform, that contains a DropDownList databound to one table, whilst SelectedValue is databound to another table

I discovered that the first time I'd load the page, the selected value was displayed correctly. However, on subsequent loading (ie: IsPostBack was true) the DropDownList always defaulted to the first value

I determined that the DropDownList was empty (of course) on the first loading, but having values already there on subsequent loadings caused the problem. Now I "DropDownList.Items.Clear();" on each reload to empty the list and cause the right value to display

My question is: why does it behave this way? This seems the wrong behaviour, and I'd *really* like to get to the bottom of it

Simon

P.S. I can duplicate the solution if I disable "EnableViewState" and delete "DropDownList.Items.Clear();"

I can duplicate problem by implementing solution, then after "this.DataBind();" adding "DropDownList.DataBind();"

Nov 18 '05 #1
Share this question for a faster answer!
Share on Google+

This discussion thread is closed

Replies have been disabled for this discussion.