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

Multi select combobox items which are dynamically loaded.

4 Answers 339 Views
ComboBox
This is a migrated thread and some comments may be shown as answers.
nagarjun
Top achievements
Rank 1
nagarjun asked on 14 Apr 2009, 02:18 PM
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.

4 Answers, 1 is accepted

Sort by
0
Axel
Top achievements
Rank 2
answered on 03 Oct 2009, 01:04 PM
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
0
Axel
Top achievements
Rank 2
answered on 03 Oct 2009, 01:11 PM
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
0
Accepted
Yana
Telerik team
answered on 07 Oct 2009, 10:30 AM
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.
0
Axel
Top achievements
Rank 2
answered on 07 Oct 2009, 12:42 PM
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();  
 
 

 

 

Tags
ComboBox
Asked by
nagarjun
Top achievements
Rank 1
Answers by
Axel
Top achievements
Rank 2
Yana
Telerik team
Share this question
or