5 Answers, 1 is accepted
0
Hello Allan,
You can check using the following code, assuming "item" is the current TreeListDataItem object you are checking:
All the best,
Tsvetina
the Telerik team
You can check using the following code, assuming "item" is the current TreeListDataItem object you are checking:
if
(item.ChildItems.Count>0)
{
//code here
}
All the best,
Tsvetina
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now
0

Allan
Top achievements
Rank 1
answered on 01 Feb 2012, 06:34 PM
Thanks Tsvetina, for ur fast reply!
But I still can't check those child.
How can I check it using the code above?
But I still can't check those child.
How can I check it using the code above?
For
Each
TreeListItems
As
TreeListDataItem
In
RadTreeList1.Items
Next
0

Princy
Top achievements
Rank 2
answered on 02 Feb 2012, 05:42 AM
Hello,
Try the following.
VB:
Thanks,
Princy.
Try the following.
VB:
For
Each
item
As
TreeListDataItem
In
RadTreeList1.Items
If
item.ChildItems.Count > 0
Then
//your code
End
If
Next
Thanks,
Princy.
0

Allan
Top achievements
Rank 1
answered on 02 Feb 2012, 12:36 PM
Thanks Princy,
I used your code, but still can't count the childitems.
It's show the error message : ChildItems is not a member of Telerik.Web.UI.TreelistDataItem
Can you help me?
Thanks,
Allan.
I used your code, but still can't count the childitems.
It's show the error message : ChildItems is not a member of Telerik.Web.UI.TreelistDataItem
Can you help me?
Thanks,
Allan.
0
Hi Allan,
It seems that you are using an older version of RadControls which does not expose this property yet. It would be best if you could upgrade to the latest version.
If this is not possible, you would need to loop through all visible TreeListDataItem objects and collect those which have a parent id corresponding to the id of the current item. Something like:
Greetings,
Tsvetina
the Telerik team
It seems that you are using an older version of RadControls which does not expose this property yet. It would be best if you could upgrade to the latest version.
If this is not possible, you would need to loop through all visible TreeListDataItem objects and collect those which have a parent id corresponding to the id of the current item. Something like:
Protected
Sub
RadTreeList1_PreRender(sender
As
Object
, e
As
EventArgs)
Dim
parent
As
TreeListDataItem = RadTreeList1.Items(0) //instead of this line, access the item you need to find the children of
Dim
id
As
String
= parent.GetDataKeyValue(
"ID"
).ToString()
Dim
children
As
New
TreeListDataItemCollection()
For
Each
item
As
TreeListDataItem
In
RadTreeList1.Items
If
item.GetParentDataKeyValue(
"ParentID"
) IsNot
Nothing
AndAlso
item.GetParentDataKeyValue(
"ParentID"
).ToString() = id
Then
children.Add(item)
End
If
Next
'use children collection
End
Sub
Greetings,
Tsvetina
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now