RadComboBox problem with SelectedValue

3 posts, 1 answers
  1. Olivier
    Olivier avatar
    146 posts
    Member since:
    Nov 2010

    Posted 29 Jan 2015 Link to this post

    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. Answer
    Nencho
    Admin
    Nencho avatar
    1457 posts

    Posted 03 Feb 2015 Link to this post

    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.

     
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Olivier
    Olivier avatar
    146 posts
    Member since:
    Nov 2010

    Posted 03 Feb 2015 in reply to Nencho Link to this post

    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);
    }
Back to Top