Multiple Selections

4 posts, 0 answers
  1. David Penny
    David Penny avatar
    174 posts
    Member since:
    Jun 2006

    Posted 17 Feb 2009 Link to this post

    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
  2. Yana
    Admin
    Yana avatar
    4554 posts

    Posted 18 Feb 2009 Link to this post

    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.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. David Penny
    David Penny avatar
    174 posts
    Member since:
    Jun 2006

    Posted 18 Feb 2009 Link to this post

    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
  5. David Penny
    David Penny avatar
    174 posts
    Member since:
    Jun 2006

    Posted 18 Feb 2009 Link to this post

    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
Back to Top