Multi select combobox items which are dynamically loaded.

5 posts, 1 answers
  1. nagarjun
    nagarjun avatar
    21 posts
    Member since:
    Jan 2009

    Posted 14 Apr 2009 Link to this post

    Hi,

        I need to have a multiselect radcombobox. I have referred to the examples provided in Url: http://www.telerik.com/community/code-library/aspnet-ajax/combobox/using-checkboxes-for-multi-item-selection.aspx.

      It was really great. Here the problem is i will not add items at client side. In my project i have to add items in to combobox dynamically as :
    for(int i=0; i<3; i++)
    {
    RadComboBoxItem rcb = new RadComboBoxItem(i.ToString());

    RadComboBox1.Items.Add(rcb);   // RadComboBox1 is the name of combobox.
    }

    I tried to modify example which you have given. I have removed items part and added items as shown above. I was able to see the checkbox's for items but not the text of RadComboBox. When i have selected some of them and clicked button to display which items were selected then luckly i could see the correct items which i have checked.

    The only problem is i could't see items text, but could see checkbox's for items. Hope you give some idea in this.


    Thanks
    Nagarjun S.
  2. Axel
    Axel avatar
    41 posts
    Member since:
    Jul 2009

    Posted 03 Oct 2009 Link to this post

    hi Nagarajun

    You've propably solved this by now but the binding to "Text" below actually binds to the radComboboxItem.Text attribute. I got it to work at least.

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

    best of luck
    Axel
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Axel
    Axel avatar
    41 posts
    Member since:
    Jul 2009

    Posted 03 Oct 2009 Link to this post

    Hi again,

    On a related matter.

    I got my multiselect radcombo to work. My combobox is databound, and has a "Select all" as a first item in the itemcollection.
    when I bind my dynamic data to the combobox everything is fine except the first item only has a check box but no text ie. not bound to anything as expected.

    What is the best/easyest way to display my "Select all" text in the first comboboxlistitem next to the checkbox?

    reg.
    Axel G
  5. Answer
    Yana
    Admin
    Yana avatar
    4554 posts

    Posted 07 Oct 2009 Link to this post

    Hi Axel,

    Please call DataBind() method of the first item when you add it to the Items collection of the combobox. Let us know how it goes.

    Greetings,
    Yana
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
  6. Axel
    Axel avatar
    41 posts
    Member since:
    Jul 2009

    Posted 07 Oct 2009 Link to this post

    Hi Yana,

    This worked like a charm. I added databind() (see below) and vola.

    thanks.
    Axel

     

     

     

    ddlDivisions.Items[0].Text = "All";   
    ddlDivisions.Items[0].Value = "-1";   
    ddlDivisions.Items[0].DataBind();  
     
     

     

     

Back to Top
UI for ASP.NET Ajax is Ready for VS 2017