New to Telerik UI for ASP.NET AJAXStart a free 30-day trial

Using the GetItems(itemType) Method

In some scenarios you may need to access the treelist items outside of the item events. This is easy to do using the GetItems(itemType) method.

Using GetItems(itemType)

The method accepts one parameter from the TreeListItemType enumerator and returns an array of all items from the RadTreeList instance that match the item type. Below you can see all the values of the enumerator and what types they return

 

TreeListItemType valueReturned object
AlternatingItemA collection of all visible TreeListDataItem instances which ItemType value is AlternatingItem
DetailTemplateItemA collection of all TreeListDetailTemplateItem objects
EditFormItemA collection of all TreeListEditForm objects
EditItemA collection of all TreeListDataItem objects that are currently edited
FooterItemA collection of all TreeListFooterItem objects
HeaderItemA collection of all TreeListHeaderItem objects
ItemA collection of all visible TreeListDataItem instances which ItemType value is Item
NoRecordsTemplateItemA collection of all TreeListNoRecordsItem objects
PagerItemA collection of all TreeListPagerItem objects
SelectedItemA collection of all selected TreeListDataItem objects on the current page

Following is a sample of how you can use the method to access different treelist items:

C#
protected void RadTreeList1_PreRender(object sender, EventArgs e)
{
	//the detail item of the first data item in the RadTreeList control
	TreeListDetailTemplateItem detailItems = RadTreeList1.GetItems(TreeListItemType.DetailTemplateItem)[0] as TreeListDetailTemplateItem;  

	//the header item
	TreeListHeaderItem header = RadTreeList1.GetItems(TreeListItemType.HeaderItem)[0] as TreeListHeaderItem;
   
   //the first alternating data item
	TreeListDataItem altItem = RadTreeList1_NeedDataSource.GetItems(TreeListItemType.AlternatingItem)[0] as TreeListDataItem;
}

See Also

In this article
Using GetItems(itemType)See Also
Not finding the help you need?
Contact Support