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

RadComboBox with EnableCheckAllItemsCheckBox=true behaving oddly within Repeater

1 Answer 238 Views
ComboBox
This is a migrated thread and some comments may be shown as answers.
Richard
Top achievements
Rank 1
Richard asked on 15 Jan 2016, 09:05 PM

I have a Repeater object on my page.  In the Repeater ItemTemplate, I have the following RadComboBox

<telerik:RadComboBox ID="rcboList"
CheckBoxes="true"
EnableCheckAllItemsCheckBox="true"
runat="server" />

When this portion of my page is loaded, contents are dynamically loaded to the above combo box, depending on certain criteria.  To further clarify, for each item in the repeater, the contents within rcboList are different.

 All though the contents are different, each repeated RadComboBox should behave the same, with a CheckBox beside each item.  I can populate my lists and I see these check boxes without issue, however, when my user clicks the button to return the data to the server, there is no data in rcboList.CheckedItems.  I figured I tried to iterate over the RadComboBox.Items collection and see if I could get the values from their.

 Interestingly, only the first item in the list is marked as selected, but none of the items are marked as checked.

 Can I use the RadComboBox this way in an asp:Repeater, or is this simply not possible?

 Thank you.

1 Answer, 1 is accepted

Sort by
0
Veselin Tsvetanov
Telerik team
answered on 20 Jan 2016, 11:39 AM
Hello Richard,

Thank you for contacting Telerik Support.

You can use the RadComboBox control in the described scenario. However, it is important to know that getting the checked (or selected) values of each of the RadComboBoxes would be a bit more complicated than the usual.

Attached you will find a simple web page implementing the scenario. You can see in detail the OnClick event handler of the RadButton control. In it you first get the collection of all controls within the repeater, then you get each of the RadComboBoxes and for each of them you can get its checked values:
protected void db1_Click(object sender, EventArgs e)
{
    ControlCollection repeaterItems = Repeater1.Controls;
    string checkedValues = "";
    for (int i = 0; i < repeaterItems.Count; i++)
    {
        Control currentRepeaterItem = repeaterItems[i];
        ControlCollection currentRepeaterItemControlCollection = currentRepeaterItem.Controls;
        RadComboBox currentCombo = (RadComboBox) currentRepeaterItemControlCollection[1];
        var checkedItems = currentCombo.CheckedItems;
        for (int j = 0; j < checkedItems.Count; j++)
        {
            checkedValues += checkedItems[j].Text;
            checkedValues += " ";
        }
    }
 
    texTitle1.Text = checkedValues;
}

I hope that the above answer helps you. If you have any further questions, please do not hesitate to contact us.

Regards,
Veselin Tsvetanov
Telerik
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
Tags
ComboBox
Asked by
Richard
Top achievements
Rank 1
Answers by
Veselin Tsvetanov
Telerik team
Share this question
or