Avatar of GRCHELPDESK
GRCHELPDESK
 asked on

Dropdown List - reverting to wrong item on postback

Hello Experts,

I have a dropdown list which is populated based on based on another dropdown list.
This part if working fine.  Values in the dropdown list are similar to this:

Text - Value
CKN - F
CQN - F
CDN - F
DKN - P
DQN - P
DDN - P

The problem I'm running into is that if you select CQN or CDN it changes to CKN on postback.  Also, if you select DQN or DDN, it changes to DKN on postback.  I don't have any logic in place to do that.  I'm suspecting it has to do with different selections having the same value ... but I still don't understand why it's happening or how to fix it.

Thanks,
GRCHELPDESK
ASP.NET

Avatar of undefined
Last Comment
GRCHELPDESK

8/22/2022 - Mon
Bob Learned

How are you checking for post-back in the Page_Load and doing something different?

Bob
GRCHELPDESK

ASKER
My pageload only has a small section:
If not page.ispostback then
     'initialize the form
End if

So that shouldn't be affecting a postback.  I have the dropdown list setup to do an auto-postback.  But I removed that and tried manually doing a postback and got the same results.  I'm stumped.
GRCHELPDESK

ASKER
Ok, silly question ... is it ok to have multiple selections in the dropdown list with different text but the same values?

Text - Value
CKN - F
CQN - F
CDN - F
DKN - P
DQN - P
DDN - P

I've always assumed that was fine, but this is the first time I've actually tried it.  The reason I ask is because it always reverts back to the first instance of with the selected value.  So if you select CDN (value F) it reverts to CKN.  If you select DQN (value P) it reverts to DKN.

If anyone has input on this I'd appreciate it, I need to get this project rolled out ASAP.
All of life is about relationships, and EE has made a viirtual community a real community. It lifts everyone's boat
William Peck
ASKER CERTIFIED SOLUTION
Bob Learned

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
GRCHELPDESK

ASKER
Actually that explains a lot.  This was the first time I ever needed to have multiple values being the same ... it didn't occur to me they needed to be unique.  I can do a work-around easily enough, but it means another hit on the database.  Oh well, what'cha gonna do.

Thanks for the help bob!
GRCHELPDESK