Log In
Home
Support
Demos
Documentation
Blogs
Training
Webinars
[Expand]General Information
[Expand]WinForms Controls
[Collapse]ASP.NET Controls and MVC Extensions
 [Expand]Prerequisites
 [Expand]What's Installed
 [Expand]Common Concepts
 [Collapse]ASP.NET WebForms Controls
  [Expand]Reporting
  [Expand]Chart Control
  [Expand]Grid View
  [Expand]Card View
  [Expand]Vertical Grid
  [Expand]Spreadsheet
  [Expand]Rich Text Editor
  [Expand]Image and Data Browsing
  [Expand]Docking and Popups
  [Expand]Site Navigation and Layout
  [Expand]File Management
  [Expand]Multi-Use Site Controls
  [Expand]Scheduler
  [Expand]HTML Editor
  [Expand]Pivot Grid
  [Collapse]Tree List
   [Expand]Product Information
   [Collapse]Concepts
    [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]Templates
     Toolbars
   [Expand]Visual Elements
   [Expand]Examples
   [Expand]Member Tables
  [Expand]Gauges
  [Expand]Data Editors
  [Expand]Spell Checker
  [Expand]Query Builder
 [Expand]ASP.NET MVC Extensions
 [Expand]Localization
 [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]Document Server
[Expand]Reporting
[Expand]Report Server
[Expand]Dashboard
[Expand]eXpressApp Framework
[Expand]CodeRush
[Expand]CodeRush Classic
[Expand]Cross-Platform Core Libraries
[Expand]Tools and Utilities
 End-User Documentation

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.

Important

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

How would you rate this topic?​​​​​​​