Skip to main content
All docs
V24.2

DevExpress v24.2 Update — Your Feedback Matters

Our What's New in v24.2 webpage includes product-specific surveys. Your response to our survey questions will help us measure product satisfaction for features released in this major update and help us refine our plans for our next major release.

Take the survey Not interested

DxTreeList.GetDataItemValue(Object, String) Method

Returns the value of the specified field for the specified data item.

Namespace: DevExpress.Blazor

Assembly: DevExpress.Blazor.v24.2.dll

NuGet Package: DevExpress.Blazor

#Declaration

C#
public object GetDataItemValue(
    object dataItem,
    string fieldName
)

#Parameters

Name Type Description
dataItem Object

The data item whose field value should be returned.

fieldName String

The name of the data field whose value should be returned.

#Returns

Type Description
Object

The field value.

#Remarks

Call the GetDataItemValue method when the TreeList is bound to a collection of anonymous objects. In other cases, you can cast a data item to a required type and use the {DataItem.FieldName} notation instead. You can also call the GetRowValue(Int32, String) method to get a field value for a data row with the specified visible index.

The following example calls the GetDataItemValue method to get the selected data item’s Name:

Razor
<style>
    .my-button {
        width: 200px;
    }
</style>

<DxTreeList @ref="MyTreeList"
            Data="TreeListData"
            KeyFieldName="Id"
            ParentKeyFieldName="ParentId"
            SelectionMode="TreeListSelectionMode.Single"
            @bind-SelectedDataItem="@SelectedDataItem">
    <Columns>
        <DxTreeListSelectionColumn />
        <DxTreeListDataColumn FieldName="Name" Caption="Task" />
        <DxTreeListDataColumn FieldName="EmployeeName" />
        <DxTreeListDataColumn FieldName="StartDate" />
        <DxTreeListDataColumn FieldName="DueDate" />
    </Columns>
</DxTreeList>
<p />
<DxButton Click="OnGetSelectedTask" CssClass="my-button" Text="Get Selected Task" />
<p />
Selected Task: @SelectedTaskInfo

@code {
    ITreeList MyTreeList { get; set; }
    object TreeListData { get; set; }
    object SelectedDataItem { get; set; }
    string SelectedTaskInfo { get; set; }

    void OnGetSelectedTask() {
        SelectedTaskInfo = (string)MyTreeList.GetDataItemValue(SelectedDataItem, "Name");
    }
}

Blazor TreeList Get Data Item Value

See Also