Add Custom attributes dynamically in RadComboBox

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

    Posted 02 Oct 2015 Link to this post


     I need to add programmatically Custom Attributes in RadComboBox

     i get an error on click button to get a value for custom Attributes

     this.LBL_MOVIE.Text = this.PCB_MOVIE.SelectedItem.Attributes["movie_p"]; 

    Cause this.PCB_MOVIE.SelectedIndex is equals to -1

    protected void PCB_MOVIE_ItemDataBound(object sender, RadComboBoxItemEventArgs e)

  2. Ivan Danchev
    Ivan Danchev avatar
    788 posts

    Posted 07 Oct 2015 Link to this post


    The RadComboBox' SelectedIndex property will return -1 if none of its items is selected. If at that moment you use it to access an item in the ComboBox' items collection, for example:
    string attr = RadComboBox1.Items[RadComboBox1.SelectedIndex].Attributes["movie_p"];
    an ArgumentOutOfRangeException exception will be returned.
    If an item is selected the SelectedIndex property will correctly return its index and you will be able to use the property's value.

    Ivan Danchev
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
  3. DevCraft R3 2016 release webinar banner
Back to Top