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

Programmatically adding items to a multicheckbox dropdown

1 Answer 54 Views
ComboBox
This is a migrated thread and some comments may be shown as answers.
Rob
Top achievements
Rank 1
Rob asked on 15 Sep 2008, 07:25 PM
I am having trouble getting the text to show up next to the checkbox in the following code:
<telerik:RadComboBox ID="FieldsToInclude" runat="server" AllowCustomText="false" EmptyMessage="* (all)" HighlightTemplatedItems="true">  
    <Items> 
    </Items> 
    <ItemTemplate>   
        <asp:CheckBox runat="server" ID="CheckBox" Text=""/>&nbsp;  
        <%# DataBinder.Eval(Container, "Text") %>   
    </ItemTemplate>   
</telerik:RadComboBox> 
 

I am populating this drop-down on a postback from another drop-down as below:
    protected void TableList1_SelectedIndexChanged(object sender, EventArgs e)  
    {  
        FieldsToInclude.Items.Clear();  
        FieldsToInclude.Items.Add(new RadComboBoxItem("test1", "1"));  
        FieldsToInclude.Items.Add(new RadComboBoxItem("test2", "2"));  
        FieldsToInclude.Items.Add(new RadComboBoxItem("test3", "3"));  
        FieldsToInclude.Items.Add(new RadComboBoxItem("test4", "4"));  
        FieldsToInclude.Items.Add(new RadComboBoxItem("test5", "5"));  
    }  
 
 

The checkboxes do show up, but the text from the <%# DataBinder.Eval(Container, "text") %> does not show up.  How can I get text populated next to the checkboxes?

Cheers
Rob

1 Answer, 1 is accepted

Sort by
0
Rob
Top achievements
Rank 1
answered on 15 Sep 2008, 07:29 PM
Oh duh,

I added FieldsToInclude.DataBind(); after adding the items and it works.

-Rob
Tags
ComboBox
Asked by
Rob
Top achievements
Rank 1
Answers by
Rob
Top achievements
Rank 1
Share this question
or