Dropdown list control problem

J

Jerry

I have a dropdown list and I am linking it to a database
table called "Product". The fields in the database are
ProductID (PK), price, and description. I am assigning
the description field from the DB to the text field (what
gets displayed) in the dropdown. I am assigning the
price from the DB to the Value in the dropdown list.


Data:
the second item in the list has a price of 10.00 and the
fourth item in the list also has a price of 10.00. All
of the other prices are different.

Problem: When you click the fourth item the second item
is displayed. So it appears that .NET is using the value
field and displaying the first record it sees with that
value rather than using the index of the dropdown list.
This seems to me to be a .NET bug.

Any ideas?

Thanks,

Jerry
 
R

Robert Koritnik

You never get the index. DropDown list's property SelectedItemIndex gets set
according to value field returned.

You could either:
1. inherit this control and appropriately set SelectedItemIndex acording to
Value & Text

2. It's actually strange to put something nonunique in the Value filed.
Change the Value field or concat it with a unique value and split both
values on the server to get the correct item index.
 

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

No members online now.

Forum statistics

Threads
473,768
Messages
2,569,575
Members
45,053
Latest member
billing-software

Latest Threads

Top