Manually Adding RadComboBoxItems - all items are blank

2 posts, 0 answers
  1. Michael Hunt
    Michael Hunt avatar
    42 posts
    Member since:
    Aug 2009

    Posted 30 Aug 2012 Link to this post

    Hi, I'm using ASP.NET AJAX version 2011.3.1305.35.

    I'm trying to do something as simple as:
    1)  Add all RadComboBoxItems to the combobox by looping through a List.
    2)  Add an Attribute to each RadComboBoxItem, in that same loop.

    When I bind the combo box by setting the DataSource Property to my List, the items display as expected. 

    When I loop through the List and add the items and attributes, all of the items and  attributes are added, but the items do NOT display in the combo box.  The combo box appears blank / empty.

    I can tell they are there though, by using a javascript Alert on the selectedindexchanged event of the combo box.

    The combo box displays in a Rad Grid row, when the row is in edit mode.
    The combo box is populated during the ItemDataBound event of the RadGrid, when the row is put into edit mode.

    My code follows (but I've tried a whole bunch of variations of it):

    I've tried not doing a DataBind;  I've tried doing the DataBind after adding all of the items, I've tried setting the AppendDataBoundItems property to True.  No matter what I do, my combo box is populated BUT IT displays as being EMPTY / BLANK.

    comboBox.DataValueField = "emEventID"
    comboBox.DataTextField = "emEventTitle"
    Dim cbItem As RadComboBoxItem
    For Each project As EM_EventsItem In filteredEventsList
        cbItem = New RadComboBoxItem(project.emEventTitle, project.emEventID)
        cbItem.Attributes.Add("UserPermissionLevel", project.UserPermissionLevel)

  2. Nencho
    Nencho avatar
    1796 posts

    Posted 03 Sep 2012 Link to this post

    Hello Michael,

    Could you try to add the desired Attributes on the server-side event OnItemDataBound, which will be fired for each added item after the first DataBind() method in the given snippet of code?
    In addition, once you have pointed to the DataValueField and the DataTextField values, you don't need to recreate the items with "New RadComboBoxItem".

    If the aforementioned approach is not helpful for your scenario, I would like to ask you to open a Support Ticket and provide us a runnable sample, which demonstrates the described problem.

    the Telerik team
    If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
Back to Top