This is a migrated thread and some comments may be shown as answers.

RadComboBox return wrong selected value if 2 or more item has same text

3 Answers 215 Views
ComboBox
This is a migrated thread and some comments may be shown as answers.
guillaume.lebel
Top achievements
Rank 1
Iron
Iron
guillaume.lebel asked on 19 May 2011, 09:37 PM
Hi,

I have a radcombobox who have some item with the same text(ex: Item1, Item1), but both has a different value. But when i want to get the selectedValue of the second one, it always return me the first item value.

Is the a way to return the good value even if there two or more item that has the same text.

Thx for your help,

Guillaume

3 Answers, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 20 May 2011, 06:34 AM
Hello Guillaume,

I have tried the same and that worked as expected at my end. Here am pasting my code.
aspx:
<telerik:RadComboBox ID="RadComboBox1" runat="server"
onselectedindexchanged="RadComboBox1_SelectedIndexChanged" AutoPostBack="true">
<Items>
  <telerik:RadComboBoxItem Text="12345"  Value="1"/>
  <telerik:RadComboBoxItem Text="12345" Value="2" />
  <telerik:RadComboBoxItem Text="12345" Value="3" />
  <telerik:RadComboBoxItem Text="12345"  Value="4"/>
  <telerik:RadComboBoxItem Text="12345" Value="5" />
  <telerik:RadComboBoxItem Text="12345" Value="6" />
</Items>
</telerik:RadComboBox>
C#:
protected void RadComboBox1_SelectedIndexChanged(object sender, Telerik.Web.UI.RadComboBoxSelectedIndexChangedEventArgs e)
   {
       Response.Write(RadComboBox1.SelectedValue);
   }

Thanks,
Shinu.
0
Tony
Top achievements
Rank 1
answered on 24 Oct 2014, 09:40 PM
I am having the same issue. If I change the DataTextValue of one of the items such that the DataTextValues are now unique, it will select the correct one. I am setting the datasource in code and calling the databind method instead of manually defining them like the example above.
0
Nencho
Telerik team
answered on 29 Oct 2014, 12:15 PM
Hello Tony,

I am not quite sure that I had understood how exactly you have your RadComboBox implemented at your end. Could you specify what DataText and DataValue fields have you set and which are the unique fields. Generally, in order to have the selection correctly behaving, you need to ensure that the Values of the RadComboBoxItems are unique. Please provide us with the implementation that you use at your end, so we could inspect it.

Regards,
Nencho
Telerik
 

Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

 
Tags
ComboBox
Asked by
guillaume.lebel
Top achievements
Rank 1
Iron
Iron
Answers by
Shinu
Top achievements
Rank 2
Tony
Top achievements
Rank 1
Nencho
Telerik team
Share this question
or