Kurt
Regular
Hi,
I was doing something with a dropdownlist, but - at least in my eyes - weird things happen. Whenever a user makes a selection from a dropdownlist, the listindex property of the dropdownlist is set to the LOWEST listindex with the same 'item-value' as the selection made. What I mean is the folowing... Suppose you have a dropdownlist with folowing items;
Whenever a user selects item6, in the code behind the SelectedIndex property of the DropDownList reports 1, so the code behind is informed that item2 was choosen!!!
I know that in HTML, values should be unique and that propably gives an explanation of what's going on. But in the Microsoft documentation under System.Web.UI.WebControls.ListItem you will find that listitems can be used as folows;
I was doing something with a dropdownlist, but - at least in my eyes - weird things happen. Whenever a user makes a selection from a dropdownlist, the listindex property of the dropdownlist is set to the LOWEST listindex with the same 'item-value' as the selection made. What I mean is the folowing... Suppose you have a dropdownlist with folowing items;
Code:
text: item1 (value: 10)
text: item2 (value: 20)
text: item3 (value: 30)
text: item4 (value: 40)
text: item5 (value: 50)
text: item6 (value: 20)
Whenever a user selects item6, in the code behind the SelectedIndex property of the DropDownList reports 1, so the code behind is informed that item2 was choosen!!!
I know that in HTML, values should be unique and that propably gives an explanation of what's going on. But in the Microsoft documentation under System.Web.UI.WebControls.ListItem you will find that listitems can be used as folows;
But as stated, this would for a commercial website mean that when a customer want's to buy for example item10 that by coincidence also got the value "$1.99", item 1 would be ordered for him in stead...For example, you can display text for an item in the list control, such as "Item 1", and use the Value property to specify a value for that item, such as "$1.99".