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

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

P: n/a
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
difference.

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
problem.

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
Share this Question
Share on Google+
1 Reply


P: n/a
FOUND THE PROBLEM!!!!

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.