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

RadTreeview in RadComboBox

6 Answers 246 Views
ComboBox
This is a migrated thread and some comments may be shown as answers.
Wicus
Top achievements
Rank 1
Wicus asked on 28 Jul 2008, 11:38 AM
Hi All...can any1 help...im using a radtreeview in a radcombobox...im bind data from sql to the treeview...my code:

       RadTreeView treeview = ((RadTreeView)Combobox2.FindControl("RadTreeView"));  
 
        foreach (DataRow dr in dtData.Rows)  
        {  
              
            RadTreeNode ParentLocationNode = new RadTreeNode();  
            ParentLocationNode.Text = (string)dr["Column"];  
            ParentLocationNode.Value = Convert.ToString(dr["Column"]);  
            treeview.Nodes.Add(ParentLocationNode);  
        } 
each time i get error: Object reference not set to an instance of an object.

plz help!

6 Answers, 1 is accepted

Sort by
0
Veselin Vasilev
Telerik team
answered on 28 Jul 2008, 12:11 PM
Hello Wicus,

You are not getting RadTreeView correctly. Please check this article:
http://www.telerik.com/help/aspnet-ajax/combobox-find-item-in-template.html

I hope this helps.

Kind regards,
Veskoni
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
Wicus
Top achievements
Rank 1
answered on 28 Jul 2008, 12:35 PM
Hi...thnkx for the reply im using this code now:

RadTreeView tree = (RadTreeView)cboLocation.Items[0].FindControl("trvLocations");

but i get this error now:

Index was out of range. Must be non-negative and less than the size of the collection.
Parameter name: index

Wat am i doing wrong now?

0
Veselin Vasilev
Telerik team
answered on 28 Jul 2008, 01:22 PM
Hello Wicus,

Can you please isolate the problem in a small project and send it to us so we can find easily where the problem is?

Thanks

Sincerely yours,
Veskoni
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
Wicus
Top achievements
Rank 1
answered on 29 Jul 2008, 06:46 AM
Hi unfortunatly i am not able to provide to much code....company descretion...here is were i use the code:

HTML:
                               <telerik:radcombobox id="cboLocation" runat="server" skin="Telerik" Height="17px">  
                                        <CollapseAnimation Type="OutQuint" Duration="200"></CollapseAnimation> 
                                    <ItemTemplate> 
                                        <telerik:RadTreeView ID="trvLocations" runat="server" EnableEmbeddedSkins="False" Height="100%" Width="50%">  
                                            <CollapseAnimation Duration="100" Type="OutQuint" /> 
                                            <ExpandAnimation Duration="100" /> 
                                        </telerik:RadTreeView> 
                                    </ItemTemplate> 
                                </telerik:radcombobox> 

C#:
        RadTreeView tree = (RadTreeView)cboLocation.Items[0].FindControl("trvLocations");  
 
 
        foreach (DataRow dr in dtData.Rows)  
        {  
            RadTreeNode ParentLocationNode = new RadTreeNode();  
            ParentLocationNode.Text = (string)dr["Location"];  
            ParentLocationNode.Value = Convert.ToString(dr["LocationID"]);  
        } 
0
Accepted
Veselin Vasilev
Telerik team
answered on 29 Jul 2008, 03:31 PM
Hello Wicus,

Do you have at least one item in the combobox?
If not, please add one with empty text.

All the best,
Veskoni
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
Wicus
Top achievements
Rank 1
answered on 30 Jul 2008, 11:32 AM
hey...thnx for your help...rlly appretiated....got it now...it works...thnx again!
Tags
ComboBox
Asked by
Wicus
Top achievements
Rank 1
Answers by
Veselin Vasilev
Telerik team
Wicus
Top achievements
Rank 1
Share this question
or