Hello,
Consider the following html code:
How do I from codebehind databind the checkboxlist ?
If I try (checkboxlist)rcbEnvironments.FindControl("cblEnvironments"), I get a null.
Thanks,
Nicolas
Consider the following html code:
| <telerik:RadComboBox runat="server" AutoPostBack="true" Skin="Hay" ID="rcbEnvironments"> |
| <ItemTemplate> |
| <asp:CheckBoxList runat="server" DataTextField="Name" DataValueField="Id" ID="cblEnvironments" /> |
| </ItemTemplate> |
| </telerik:RadComboBox> |
How do I from codebehind databind the checkboxlist ?
If I try (checkboxlist)rcbEnvironments.FindControl("cblEnvironments"), I get a null.
Thanks,
Nicolas
5 Answers, 1 is accepted
0
Hi NS,
The template is instantiated in the context of the specific item, but not the RadComboBox control. Therefore you should use
RadComboBoxItem item = rcbEnvironments.Items[0];
CheckBoxList myList = (CheckBoxList)item.FindControl("cblEnvironments");
I hope this helps.
Kind regards,
Erjan Gavalji
the Telerik team
Instantly find answers to your questions at the new Telerik Support Center
The template is instantiated in the context of the specific item, but not the RadComboBox control. Therefore you should use
RadComboBoxItem item = rcbEnvironments.Items[0];
CheckBoxList myList = (CheckBoxList)item.FindControl("cblEnvironments");
I hope this helps.
Kind regards,
Erjan Gavalji
the Telerik team
Instantly find answers to your questions at the new Telerik Support Center
0
NS
Top achievements
Rank 1
answered on 05 May 2008, 03:19 PM
Hi,
I get a Index was out of range. Must be non-negative and less than the size of the collection. Parameter name: index at System.Collections.ArrayList.get_Item(Int32 index) exception at the line: RadComboBoxItem item = rcbEnvironments.Items[0];
Must I databind my datasource to the radcombobox ?
I get a Index was out of range. Must be non-negative and less than the size of the collection. Parameter name: index at System.Collections.ArrayList.get_Item(Int32 index) exception at the line: RadComboBoxItem item = rcbEnvironments.Items[0];
Must I databind my datasource to the radcombobox ?
0
NS
Top achievements
Rank 1
answered on 05 May 2008, 03:23 PM
Already answered my own question :-) I must indeed databind my datasource to the radcombobox first.
Nicolas
Nicolas
0
NS
Top achievements
Rank 1
answered on 06 May 2008, 07:38 AM
I have some extra questions.
When I expand my radcombobox, my asp:checkboxlist appear. I want to select some items in the checkboxlist.
Problem is when I select one thing, my radcombobox collapses again. I have to expand the radcombobox to select the next thing.
Next question:
Where do I handle the selectedindexchanged of the asp:checkboxlist ? (to get all the checked items), the asp:checkboxlist is not known in codebehind because it is inside a radcombobox.
Thanks,
Nicolas
When I expand my radcombobox, my asp:checkboxlist appear. I want to select some items in the checkboxlist.
Problem is when I select one thing, my radcombobox collapses again. I have to expand the radcombobox to select the next thing.
Next question:
Where do I handle the selectedindexchanged of the asp:checkboxlist ? (to get all the checked items), the asp:checkboxlist is not known in codebehind because it is inside a radcombobox.
Thanks,
Nicolas
0
Hello NS,
Sincerely yours,
Nick
the Telerik team
Instantly find answers to your questions at the new Telerik Support Center
- You can hook on the OnClientSelectingIndexChanging event of the combobox and call the event arguments' set_cancel(true) method to cancel the event. Thus, the drop-down will not be closed when checking a checkbox:
function OnClientSelectedIndexChanging(sender, args)
{
args.set_cancel(true);
} - As for the selectedindexchangedof the checkbox list - you should simply hook on the event as if the checkboxlist was not in a combobox' tempate and execute your logic in the event handler
Sincerely yours,
Nick
the Telerik team
Instantly find answers to your questions at the new Telerik Support Center
