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

RadComboBox problem with SelectedValue

2 Answers 64 Views
ComboBox
This is a migrated thread and some comments may be shown as answers.
Olivier
Top achievements
Rank 2
Olivier asked on 29 Jan 2015, 04:40 PM
Hello

I have a little problem with selectedValue,

If a dataValueField contain space , i don't get the selectedvalue.


this.PCB.Items.Add(new Telerik.Web.UI.RadComboBoxItem("LOCATION","L ");
this.PCB.Items.Add(new Telerik.Web.UI.RadComboBoxItem("VENTE","V ");
this.PCB.Items.Add(new Telerik.Web.UI.RadComboBoxItem("LOCATION MEUBLE","LM");
this.PCB.Items.Add(new Telerik.Web.UI.RadComboBoxItem("VENTE COMMERCE","VC");

If choose

this.PCB_TYPE_TRANS.SelectedValue="LM";  it's works
this.PCB_TYPE_TRANS.SelectedValue="L"; or this.PCB_TYPE_TRANS.SelectedValue="L ";  it's doesn"t work

i have a space cause i add the item from database with telerik dataaccess and datasource.


thanks for your help
Olivier,






2 Answers, 1 is accepted

Sort by
0
Accepted
Nencho
Telerik team
answered on 03 Feb 2015, 09:22 AM
Hello Olivier,

I would suggest you to trim the values of the RadComboBoxItems at the OnItemDataBound event handler. Please consider the following implementation of the event handler:

protected void PCB_ItemDataBound(object sender, RadComboBoxItemEventArgs e)
 {
     e.Item.Value = e.Item.Value.Trim();
 }

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.

 
0
Olivier
Top achievements
Rank 2
answered on 03 Feb 2015, 10:11 AM
Hello ,

Thanks nencho, it's great.

i have inherit object , i write this override method

protected override void OnItemDataBound(RadComboBoxItemEventArgs e)
{
    e.Item.Value = e.Item.Value.Trim();
    base.OnItemDataBound(e);
}
Tags
ComboBox
Asked by
Olivier
Top achievements
Rank 2
Answers by
Nencho
Telerik team
Olivier
Top achievements
Rank 2
Share this question
or