Listbox selected value is not picking the correct value

quotemachine

New Member
I have some data in Table:Table_Test having data as mentioned below:\[code\]ID CountryCode CountryName1 XXX Test_12 XXX Test_2\[/code\]The above data is bound to a listbox. Now in the above data, we have a duplicate country code. For the listbox, I have used \[code\]DataTextField="CountryName" DataValueField="CountryCode"\[/code\].\[code\]foreach (ListItem item in _lstTest.Items){ if (item.Selected) { Test optIn = new Test(); optIn.abc_Name = yyyyBll.GetWhereCountryCodeEquals(item.Value).Test; optIn.country_code = item.Value; optIn.country_name = item.Text; optIn.ID = xxxx.ID; optIn.ID = 0; xxxx mfpa = xxxBll.Insert(optIn); }}\[/code\]I have used the code to get the selected data from the listbox. But it is picking the wrong value. I am selecting Test_2 but it is taking selected value as Test_1. I referred to this post.Can anyone help me resolve this issue?
 
Back
Top