[Expand]General Information
[Expand]WinForms Controls
[Collapse]ASP.NET Controls and MVC Extensions
 [Expand]What's Installed
 [Expand]Common Concepts
 [Collapse]ASP.NET WebForms Controls
   Getting Started
  [Expand]Grid View
  [Collapse]Tree List
   [Expand]Product Information
    [Collapse]Binding to Data
      Connecting the ASPxTreeList to a Data Source
      Unbound Mode
      Virtual Mode
    [Expand]Data Representation Basics
    [Expand]Data Editing
    [Expand]Data Shaping and Manipulation
     Drag and Drop
    [Expand]Focus and Navigation
     Appearance Customization
     Save and Restore Layout
   [Expand]Visual Elements
   [Expand]Member Tables
  [Expand]Card View
  [Expand]Chart Control
  [Expand]Pivot Grid
  [Expand]Rich Text Editor
  [Expand]Site Navigation and Layout
  [Expand]HTML Editor
  [Expand]Vertical Grid
  [Expand]Data Editors
  [Expand]Docking and Popups
  [Expand]File Management
  [Expand]Data and Image Navigation
  [Expand]Multi-Use Site Controls
  [Expand]Spell Checker
  [Expand]Query Builder
 [Expand]ASP.NET MVC Extensions
 [Expand]Redistribution and Deployment
  Get More Help
 [Expand]API Reference
[Expand]ASP.NET Bootstrap Controls
[Expand]ASP.NET Core Bootstrap Controls
[Expand]WPF Controls
[Expand]Xamarin Controls
[Expand]Windows 10 App Controls
[Expand]Office File API
[Expand]Report and Dashboard Server
[Expand]eXpressApp Framework
[Expand]eXpress Persistent Objects
[Expand]CodeRush Classic
[Expand]Cross-Platform Core Libraries
[Expand]Tools and Utilities
 End-User Documentation
View this topic on docs.devexpress.com (Learn more)

Connecting the ASPxTreeList to a Data Source

The ASPxTreeList control can display data from a database, an array or collection, as well as the public properties of collection elements. There is no data access strategy that is suitable for all situations. In fact, each approach has its own advantages and disadvantages.

Since the ASPxTreeList is designed to display information in a tree structure, its data source should meet certain requirements. If a data source contains flat data, two additional fields are necessary to build a tree structure:

  • Key Field

    The first field must contain unique values. This field must be assigned to the ASPxTreeList.KeyFieldName property.

  • Parent Field

    The second field must contain values that indicate parent nodes for the current node. It should be assigned to the ASPxTreeList.ParentFieldName property.

Columns bound to these fields are called service columns.


When TreeList is bound to a hierarchical data source (e.g. XmlDataSource), the ASPxTreeList.KeyFieldName and ASPxTreeList.ParentFieldName properties are not in effect.

The most common way of accessing data in Web Forms pages is to retrieve it from a database via a data source control. To bind the ASPxTreeList to a data source, invoke its tasks and select an existing data source (if any) from the list, or create a new one.

By default, the ASPxTreeList doesn't create service columns. To automatically create columns for the ASPxTreeList.KeyFieldName and ASPxTreeList.ParentFieldName data fields, enable the ASPxTreeList.AutoGenerateServiceColumns option

The following sample code shows how the ASPxTreeList can be connected to a data source in code:

Expanded See also

Is this topic helpful?​​​​​​​