Back to Devexpress

ASPxTreeList.ParentFieldName Property

aspnet-devexpress-dot-web-dot-aspxtreelist-dot-aspxtreelist-75018068.md

latest4.0 KB
Original Source

ASPxTreeList.ParentFieldName Property

Gets or sets the data source field which contains parent node values.

Namespace : DevExpress.Web.ASPxTreeList

Assembly : DevExpress.Web.ASPxTreeList.v25.2.dll

NuGet Package : DevExpress.Web

Declaration

csharp
[DefaultValue("")]
public string ParentFieldName { get; set; }
vb
<DefaultValue("")>
Public Property ParentFieldName As String

Property Value

TypeDefaultDescription
StringString.Empty

A String value that specifies the parent field name.

|

Remarks

The data source you bind to the ASPxTreeList control should contain the following fields:

  • A Key field - a field that specifies a unique key value for each node. Assign the name of this field to the KeyFieldName property.

  • A Parent field - a field that specifies the key value of the parent node for each node. Assign the name of this field to the ParentFieldName property.

The data types of the Key and Parent fields must be the same.

Important

When the ASPxTreeList control is bound to a hierarchical data source (for instance, XmlDataSource), the KeyFieldName and ParentFieldName properties are not in effect.

The following code snippet (auto-collected from DevExpress Examples) contains a reference to the ParentFieldName property.

Note

The algorithm used to collect these code examples remains a work in progress. Accordingly, the links and snippets below may produce inaccurate results. If you encounter an issue with code examples below, please use the feedback form on this page to report the issue.

asp-net-web-forms-popup-use-one-popup-for-entire-application/CS/T501713/WebForm2.aspx.cs#L38

csharp
tree.DataBinding += (sender, e) => {
    (sender as ASPxTreeList).ParentFieldName = "Parent";
    (sender as ASPxTreeList).DataSource = Enumerable.Range(0, 10).Select(i => new { Id = i, Name = "Name" + i, Parent = i % 3 }).ToList();

asp-net-web-forms-popup-use-one-popup-for-entire-application/VB/T501713/WebForm2.aspx.vb#L36

vb
AddHandler tree.DataBinding, Sub(sender, e)
    TryCast(sender, ASPxTreeList).ParentFieldName = "Parent"
    TryCast(sender, ASPxTreeList).DataSource = Enumerable.Range(0, 10).[Select](Function(i) New With {.Id = i, .Name = "Name" & i, .Parent = i Mod 3}).ToList()

See Also

AutoGenerateServiceColumns

AutoGenerateColumns

Tree List

ASPxTreeList Class

ASPxTreeList Members

DevExpress.Web.ASPxTreeList Namespace