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

RadComboBox inside RadListBox - how to add items

1 Answer 282 Views
ListBox
This is a migrated thread and some comments may be shown as answers.
Keith
Top achievements
Rank 2
Keith asked on 24 Oct 2012, 06:42 AM

I have followed the examples found elsewhere in the forums for adding a radcombobox to a listbox. Now that I have that working, how do I add the items to the control?
In the item template I have the following:

<ItemTemplate>
   <span> <%# DataBinder.Eval(Container, "Text")%>
   <telerik:RadComboBox ID="radTimeClockIDs" runat="server" CausesValidation="False">
    <Items>
        <telerik:RadComboBoxItem Text="1" Value="1"/>
        <telerik:RadComboBoxItem Text="2" Value="2"/>
    </Items>
   </telerik:RadComboBox>
   </span>
</ItemTemplate>

In the codebehind, I am adding items to the radlistbox, but they do not appear. I suspect that is because of the item template.

Now that I have the template in place, how do I add list items programmatically? Also, preliminarily I simply placed some items in the RadComboBox that is displayed. However, I will need to be able to put different items in the combobox based on the item that is placed as the list item.

My specific scenario requires a list of items that can be checked so the information can be supplied to a database function, however, each of the items that will populate the list will have a secondary value that is part of a configuration setting. The possible configuration values should appear in the RadComboBox, but each combobox may hold different values.
Essentially it will be three columns in the listbox. One with a checkbox, one with a text value and one with a combobox that is filled based on the text value in the listitem.

Is that possible with this control? If not, is there a better solution?

Thanks!

1 Answer, 1 is accepted

Sort by
0
Accepted
Nencho
Telerik team
answered on 26 Oct 2012, 01:48 PM
Hello Keith,

Please make sure that you had invoke the DataBind() method on the RadListBox, so that  the ItemTemplate could be data bound correctly and the added items to the RadListBox should be visualized. In addition, please refer to our help article, where it is demonstrated how to add ItemTemplates in RadListBox.


Greetings,
Nencho
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.
Tags
ListBox
Asked by
Keith
Top achievements
Rank 2
Answers by
Nencho
Telerik team
Share this question
or