Reputation: 125
I have a listbox that has the following items and values right now.
Items, Misc. Charge/Taxes/Labor Charges
Value, 50.00/50.00/100.00
The problem is when i select the taxes item, it will turn it into Misc. Charges because they have the same value. Is it possible to have the listbox get the correct item and value if the values are the same??
Thank you!
Upvotes: 0
Views: 305
Reputation: 679
Use the value attribute as the unique id (miscCharge, Taxes) and the text attribute as what is displayed to the user (50.00, 50.00).
<asp:ListItem value="item1" Text="50" Selected="True"></asp:ListItem>
<asp:ListItem value="item2" Text="50"></asp:ListItem>
ListItem selectedItem = list1.SelectedItem;
string id = list1.SelectedItem.Value;
string text = list1.SelectedItem.Text;
Upvotes: 1