Hi All...can any1 help...im using a radtreeview in a radcombobox...im bind data from sql to the treeview...my code:
each time i get error: Object reference not set to an instance of an object.
plz help!
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); |
} |
plz help!
6 Answers, 1 is accepted
0
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.
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
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.
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:
C#:
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
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.
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!