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

Multiple Selections

3 Answers 97 Views
ComboBox
This is a migrated thread and some comments may be shown as answers.
David Penny
Top achievements
Rank 2
David Penny asked on 17 Feb 2009, 04:26 PM
Hi,

I have followed the example from here (http://www.telerik.com/community/code-library/aspnet-ajax/combobox/radcombobox-advanced-multiple-selection.aspx) and although the checkboxes are displayed and allow multiple selections, my combobox text is now empty. 

I am manually binding the combobox using the following:

Dim dt As DataTable  
dt = ListProjects()  
cbox.Items.Clear()  
For Each row As DataRow In dt.Rows  
    Dim item As New RadComboBoxItem()  
    item.Text = row("Name").ToString  
    item.Value = row("ID").ToString  
    cbox.Items.Add(item)  
Next 

This is getting called in PageLoad.  If I take out the Item Template it displays all my entries fine, but obviously without the checkbox.  Do I need to do something different in this scenario?

David Penny

3 Answers, 1 is accepted

Sort by
0
Yana
Telerik team
answered on 18 Feb 2009, 12:29 PM
Hi David,

When you have templates in RadComboBox, the text of the item is not shown by design, so you should add it manually in the template. In your case it can be set in Text property of the checkbox like this:

<ItemTemplate> 
    <asp:CheckBox runat="server" ID="CheckBox" onclick="checkboxClick();"  Text='<%# DataBinder.Eval(Container, "Text") %>' /> 
</ItemTemplate> 

All the best,
Yana
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.
0
David Penny
Top achievements
Rank 2
answered on 18 Feb 2009, 01:58 PM
Hi Yana,

Yes, that's what I am doing.  My definition is (taken almost directly from the example):

<telerik:RadComboBox ID="ProjectFrom" runat="server" Width="100%">  
                        <CollapseAnimation Type="OutQuint" Duration="200"></CollapseAnimation> 
                        <ItemTemplate> 
                            <asp:CheckBox runat="server" ID="CheckBox" onclick="stopPropogation();" Text='<%# DataBinder.Eval(Container, "Text") %>' /> 
                        </ItemTemplate> 
                    </telerik:RadComboBox> 

Without the ItemTemplate it shows my data values as expected.  As soon as I add the ItemTemplate I see the checkbox, but no text.  The only difference appears to be that I am loading the radcombobox in code and not manually.

David Penny
0
David Penny
Top achievements
Rank 2
answered on 18 Feb 2009, 02:03 PM
Hi again Yana,

after replying to you, I went and changed the binding code to:

dt = ListProjects(StaffID, False, SearchValue, False)  
cbox.Items.Clear()  
Dim item0 As New RadComboBoxItem("")  
item0.Value = "0" 
cbox.Items.Add(item0)  
cbox.DataTextField = "Name" 
cbox.DataValueField = "ID" 
cbox.DataSource = dt 
cbox.DataBind() 

This works now, so it must be something to do with the way I was manually binding values to the combox.

David Penny
Tags
ComboBox
Asked by
David Penny
Top achievements
Rank 2
Answers by
Yana
Telerik team
David Penny
Top achievements
Rank 2
Share this question
or