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

Own message for checked items

1 Answer 102 Views
ComboBox
This is a migrated thread and some comments may be shown as answers.
Peter
Top achievements
Rank 1
Peter asked on 15 Oct 2012, 02:45 PM
Hi, 

I use following combobox

<telerik:RadComboBox ID="rcbDaysOfWeek" runat="server" Width="150px"
    CheckBoxes="true" EnableCheckAllItemsCheckBox="true"
    EmptyMessage="No day selected">
    <Localization AllItemsCheckedString="All days" CheckAllString="Select all"  />
    <Items>
        <telerik:RadComboBoxItem Text="Monday" Value="1" Checked="true" />
        <telerik:RadComboBoxItem Text="Tuesday" Value="2" Checked="true" />
        <telerik:RadComboBoxItem Text="Wednesday" Value="3" Checked="true" />
        <telerik:RadComboBoxItem Text="Thursday" Value="4" Checked="true" />
        <telerik:RadComboBoxItem Text="Friday" Value="5" Checked="true" />
        <telerik:RadComboBoxItem Text="Saturday" Value="6" Checked="true" />
        <telerik:RadComboBoxItem Text="Sunday" Value="7" Checked="true" />
    </Items>
</telerik:RadComboBox>

Could you advice me how can I manage to have my custom message if I select 4 days - I want to have "1347" instead of "4 items checked". I want to have values of those selected checkboxed written in the message... 

Thanks a lot... 

1 Answer, 1 is accepted

Sort by
0
Kalina
Telerik team
answered on 17 Oct 2012, 03:53 PM
Hi,

I am afraid that changing the text in RadComboBox when you use CheckBoxes is not supported.
The CheckBoxes feature sets the text in the control internally by design.
You can obtain the values of the checked items via CheckedItems collection:

<telerik:RadComboBox ID="rcbDaysOfWeek" runat="server" Width="150px"
    CheckBoxes="true" EnableCheckAllItemsCheckBox="true"
    AutoPostBack="true" OnItemChecked="rcbDaysOfWeek_ItemChecked"
    EmptyMessage="No day selected">
    <Localization  AllItemsCheckedString="All days" CheckAllString="Select all"  />
    <Items>
        <telerik:RadComboBoxItem Text="Monday" Value="1" Checked="true" />
        <telerik:RadComboBoxItem Text="Tuesday" Value="2" Checked="true" />
        <telerik:RadComboBoxItem Text="Wednesday" Value="3" Checked="true" />
        <telerik:RadComboBoxItem Text="Thursday" Value="4" Checked="true" />
        <telerik:RadComboBoxItem Text="Friday" Value="5" Checked="true" />
        <telerik:RadComboBoxItem Text="Saturday" Value="6" Checked="true" />
        <telerik:RadComboBoxItem Text="Sunday" Value="7" Checked="true" />
    </Items>
</telerik:RadComboBox>
<asp:Label ID="lblValues" runat="server" ></asp:Label>

protected void rcbDaysOfWeek_ItemChecked(object sender, Telerik.Web.UI.RadComboBoxItemEventArgs e)
{
    lblValues.Text = "Checked items values: ";
    foreach(RadComboBoxItem item in rcbDaysOfWeek.CheckedItems)
        lblValues.Text += item.Value + " ";
}

All the best,
Kalina
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
Tags
ComboBox
Asked by
Peter
Top achievements
Rank 1
Answers by
Kalina
Telerik team
Share this question
or