470,819 Members | 1,592 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 470,819 developers. It's quick & easy.

HELP! dropdown control is being reset to a value on every postback!

I don't know how this is happening, but a dropdown control I have is
resetting to the 2nd value on the list anytime a postback occurs.

I have no initiation code outside of
If Not (IsPostBack)

I have EnableViewState set to true for the control - the control stays
populated, it just is losing its selected value.

The control is not contained in any panels or anything, just a Web
form, and the page's enabledViewState is also set to true.

I have tried disabling the autoPostBack of the dropdown, but it still
gets reset on any kind of postback.

I have tried enabling/disabling Smart navigation but it made no

This seems to have happened after I copied a dropdown form another
aspx page (which is identical, same name, properties, etc), and pasted
it on this screen. Now I get the problem with the control on both
screens. On both screens I have deleted the controls and dragged on
new ones, tried naming them different things, etc, but still I get
this problem.

I had a CompareValidator attached to the control, but deleted it to
see if that would help, but no such luck.

I tried to find where the control is losing its value it seems to be
getting reset before Page_Load because if I put an Exit Sub at top of
page load (moved initiation code into a button) I still get the

I started playing with events to see what is firing on postback. On
the first postback after I have changed the value,
Dropdown1_SelectedIndexChanged fires, followed by Dropdown1_PreRender.
Then on every subsequent postback Dropdown1_Load fires, followed by
PreRender. I don't know what those events are doing but maybe the
value is being reset there? Nowhere else in my app do I even reference
the dropdown except in the initialization.

I even tried rebooting my PC and still had the problem.

I fear that due to some VS glitch I may have somehow corrupted my app
when I copied/pasted the control. I am using VS.NET 2003.

Has anyone seen anything like this? Any help appreciated!
Nov 18 '05 #1
1 3465

I believe it had to do with the data not being unique.

cboCombo.Items(iCounter).Value = (my non-unique field)

I checked my SQL query I was populating the dropdown with and it
turned out to be the wrong field, and was sticking a non-unique value
into the dropdown's value property. I changed the field being returned
by SQL to the primary key (a unique value) and the problem went away.
Nov 18 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

9 posts views Thread by Tom | last post: by
4 posts views Thread by Sarir Khamsi | last post: by
6 posts views Thread by wukexin | last post: by
6 posts views Thread by d.warnermurray | last post: by
2 posts views Thread by BT Openworld | last post: by
9 posts views Thread by JJ | last post: by
reply views Thread by mihailmihai484 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.