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

Two-way databinding with RadComboBox.CheckedItems

5 Answers 441 Views
ComboBox
This is a migrated thread and some comments may be shown as answers.
Jeff
Top achievements
Rank 1
Jeff asked on 10 Nov 2011, 01:28 AM
I am trying to do two way databinding with a RadComboBox when Checkboxes="true". Getting them to save to the database is fine but binding each checked item when reading from the database isnt working. The CheckedItems property is read only so that wont work. I tried this next:

Dim branchBox As RadComboBox = FormView1.FindControl("branchBox")
For Each b As Branch In current.branches
    For Each item As RadComboBoxItem In branchBox.Items
        item.Checked = (b.branchId = item.Value)
    Next
Next

'current' is an instance of an Person entity in my Entity Framework. A Person has a collection of branches. I want to bind the RadComboBox to all of the branches for the person.

Doing the above, only the last item in the RadComboBox will be checked. So, if the person has "Army" and "Navy" as branches and Army appears before Navy in the RCB, only Navy will be checked. Army will be unchecked.

Is there a way to set multiple checkboxes in a RadComboBox in C#?

5 Answers, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 10 Nov 2011, 07:21 AM
Hello Jeff,

You can add CheckBoxes in RadComboBox as shown below.
aspx:
<telerik:RadComboBox ID="combo" runat="server" Text="Select" EmptyMessage="select" DataSourceID="SqlDataSource1" DataTextField="FirstName" DataValueField="EmployeeID">
 <ItemTemplate>
      <asp:CheckBox ID="CheckBox1" runat="server" />
      <asp:CheckBox ID="CheckBox2" runat="server" />
  </ItemTemplate>
</telerik:RadComboBox>

Also check the following help documentation.
Templates Overview.

-Shinu.
0
Accepted
Kalina
Telerik team
answered on 15 Nov 2011, 03:22 PM
Hello Jeff,

Currently we are developing a new RadComboBox property called "DataCheckedField" - a bindable property to represent the checked state of the RadComboBox items. It will define which datasource field will be used to hold the checked state of the items. "DataCheckedField" will be available in our next release (till the end of the week).

Regards,
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
0
Jeff
Top achievements
Rank 1
answered on 15 Nov 2011, 04:21 PM
Thanks Kalina. In the absence of an existing solution, that is exactly what I was hoping to hear.
0
Bilal
Top achievements
Rank 1
answered on 22 Dec 2011, 04:36 PM
Any news about when this version is going to be released?

Thanks,
Bilal
0
Kalina
Telerik team
answered on 27 Dec 2011, 05:27 PM
Hi,

In our latest Q3 2011 (version 2011.3.1115)  release we have introduced a new RadComboBox property - DataCheckedField.
You can find more details about this at the Q3 release notes and in the "CheckBox Support" help article.

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
Jeff
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
Kalina
Telerik team
Jeff
Top achievements
Rank 1
Bilal
Top achievements
Rank 1
Share this question
or