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

RadComboBox ItemTemplate

3 Answers 264 Views
ComboBox
This is a migrated thread and some comments may be shown as answers.
venm
Top achievements
Rank 1
venm asked on 04 Aug 2009, 05:42 PM
Hi,

I have a RadTreeView control inside the RadCombobox's  <Item Template>
Now I need to databind the RadTreeView from the code behind. How can I access the this control from the code behind?

Any help will be greatly appreciated.

<telerik:RadComboBox ID="RadComboBoxCategoryLevels"
                         Width="160px"
                         Height="300px"
                         AllowCustomText="false"
                         runat="server" >
                        <ItemTemplate >
                            <div onclick="StopPropagation(event)">
                                <telerik:RadTreeView ID="RadTreeView"
                                                     runat="server"
                                                     OnClientNodeClicking="OnclientNodeClickingHandler">
                                                     <DataBindings >
                                                        <telerik:RadTreeNodeBinding Depth="0" Expanded="true" />
                                                     </DataBindings>                                                     
                                </telerik:RadTreeView>
                            </div>                            
                        </ItemTemplate>                     
    </telerik:RadComboBox>

3 Answers, 1 is accepted

Sort by
0
Raj
Top achievements
Rank 1
answered on 04 Aug 2009, 06:15 PM

try :

RadComboBoxCategoryLevels.Items[0].FindControl(

"RadTreeView") as RadTreeView;


where 0 is the index of the first item in the combobox

 

0
venm
Top achievements
Rank 1
answered on 04 Aug 2009, 06:28 PM
I tried to access it

radTree = DirectCast(RadComboBoxCategoryLevels.Items(0).FindControl("RadTreeView"), RadTreeView)

I get index out of range error
Error: "Index was out of range. Must be non-negative and less than the size of the collection."

I dont have anything in my Items collection.

0
venm
Top achievements
Rank 1
answered on 04 Aug 2009, 07:07 PM
I figured out

Even though I needed  only <Item template> I have to add
<Items>
       
<telerik:RadComboBoxItem Text="" />
</Items>

as an empty item,
by this was I can access my "RadTreeView"

reference : http://www.telerik.com/help/aspnet-ajax/combobox-find-item-in-template.html
Tags
ComboBox
Asked by
venm
Top achievements
Rank 1
Answers by
Raj
Top achievements
Rank 1
venm
Top achievements
Rank 1
Share this question
or