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

[Solved] ComboBox with internal TreeView...

2 Answers 120 Views
ComboBox
This is a migrated thread and some comments may be shown as answers.
Kevin
Top achievements
Rank 1
Kevin asked on 09 Feb 2010, 09:53 PM
I've followed the example at: http://demos.telerik.com/aspnet-ajax/treeview/examples/functionality/treeviewcombobox/defaultcs.aspx

However, I need to be able to load the contents of the TreeView at runtime.  It's working fine if the treeview "exists" before the dropdown is activated, but because it's part of a template, the list is not "real" until runtime when the dropdown is used.

I've tried creating a different control and then swapping it in to no avail...

Any ideas?

2 Answers, 1 is accepted

Sort by
0
Accepted
Schlurk
Top achievements
Rank 2
answered on 10 Feb 2010, 03:50 PM
Using the same demo I can get an instance of the TreeView by using the following ASPX and C# snippets:

ASPX:
<telerik:RadComboBox ID="DiscountComboBox" runat="server" ShowToggleImage="True"
 ExpandAnimation-Type="None" CollapseAnimation-Type="None" Width="300px"
                        <ItemTemplate> 
                            <div id="div1"
                                <telerik:RadTreeView runat="server" ID="DiscountTree"
                                </telerik:RadTreeView> 
                            </div> 
                        </ItemTemplate> 
                        <Items> 
                            <telerik:RadComboBoxItem Value="TreeView" /> 
                        </Items> 
</telerik:RadComboBox> 

C#:
RadTreeView discountTree = (RadTreeView)DiscountComboBox.FindItemByValue("TreeView").FindControl("DiscountTree"); 

As you see here I defined an ItemTemplate and then simply defined a singular item with a value so that I can find it using FindItemByVaue. This should be able to work whether or not you have actually used the ComboBox.
0
Kevin
Top achievements
Rank 1
answered on 10 Feb 2010, 07:35 PM
Excellent!  Thanks!
Tags
ComboBox
Asked by
Kevin
Top achievements
Rank 1
Answers by
Schlurk
Top achievements
Rank 2
Kevin
Top achievements
Rank 1
Share this question
or