DropDownList Behaviour - why is it so?

G

Guest

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();"
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,774
Messages
2,569,596
Members
45,142
Latest member
arinsharma
Top