blazor-devexpress-dot-blazor-dot-dxtreelist-dot-getdataitemvalue-x28-system-dot-object-system-dot-string-x29.md
Returns the value of the specified field for the specified data item.
Namespace : DevExpress.Blazor
Assembly : DevExpress.Blazor.v25.2.dll
NuGet Package : DevExpress.Blazor
public object GetDataItemValue(
object dataItem,
string fieldName
)
| 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.
|
| Type | Description |
|---|---|
| Object |
The field value.
|
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 :
<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");
}
}
.my-button {
width: 200px;
}
GetDataItemValue(Object, String)
GetDataItemValue(Object, String)
See Also