ComboBox: SelectedItem getting NULL even when it is selected from the list

3 posts, 0 answers
  1. Chinthana Jayawardena
    Chinthana Jayawardena avatar
    3 posts
    Member since:
    Jul 2009

    Posted 14 Jul 2009 Link to this post

    Hi All,

    I am yet a trial version user of telerik controls. When I am using it I found an issue as mention below.
    My item list is popuplated with a item like 'Investment in Land & Building'
    When I select that, it display the text as 'Investment in Land & Building' (This is my exact item text coming from DB)
    But when I try to read the property of SelectedItem, it indicates it is NULL. But only Text property filled with the correct selected item's text. And even SelectedIndex is -1.
    I believe telerik dropdown control may be using that special character (&), but I am not sure. But I was able to get over the issue by doing some manual check of finding the SelectedItem with Server.HtmlEncode as follows.
    eg.(C# Code)
       cmbGlCode.SelectedIndex = cmbGlCode.Items.IndexOf(cmbGlCode.Items.FindItemByText(Server.HtmlEncode(cmbGlCode.Text)));

    I am reporting this because I like the controls, and my client is going to buy them.

  2. Veselin Vasilev
    Veselin Vasilev avatar
    2992 posts

    Posted 14 Jul 2009 Link to this post

    Hi Chinthana Jayawardena,

    I suppose you load the items on demand. If that is the case you need to know that items are not accessible on the server-side when loading them on demand

    You need to use either Text or SelectedValue properties.

    All the best,
    Veselin Vasilev
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Check out the tips for optimizing your support resource searches.
  3. Chinthana Jayawardena
    Chinthana Jayawardena avatar
    3 posts
    Member since:
    Jul 2009

    Posted 16 Jul 2009 Link to this post

    Hi Veselin Vasilev,

    Items are not loaded on demand or in any web service call(AJAX). This is loaded at the page post back. And this works fine for other telerik dropdowns in the same page, even the issue reported control also works if that particular item is not selected by the user.
    What I feel is something to do with the "&" in the items text value.
    because this is the only scenario that it fail. As I referred in the previous comment I was able to get over this with HtmlEncode. 

    All I can give further info is that these controls are placed inside 2 repeater controls (Parent repeater-> ChildRepeater->Dropdowns). I tried to recreate it without the repeaters it was not reproducible.I believe the only way to recreate it is, by use of repeaters.

Back to Top