Skip to main content

DxComboBoxSettings.ValueFieldName Property

Specifies the name of the data source field that contains combo box values.

Namespace: DevExpress.Blazor

Assembly: DevExpress.Blazor.v24.1.dll

NuGet Package: DevExpress.Blazor

Declaration

[DefaultValue("")]
[Parameter]
public string ValueFieldName { get; set; }

Property Value

Type Default Description
String String.Empty

A field name.

Remarks

Specify the following settings to bind the combo box editor to data:

Data
Specifies the object that supplies combo box data.
TextFieldName
Specifies the data source field that contains text for combo box items.
ValueFieldName
Specifies the name of the data source field that contains combo box values.

The following code snippet configures DxComboBoxSettings and display values from an external collection in a Grid column:

@inject IDbContextFactory<NorthwindContext> NorthwindContextFactory

<DxGrid Data="Products"
        EditMode="GridEditMode.EditRow">
    <Columns>
        <DxGridCommandColumn />
        <DxGridDataColumn FieldName="CategoryId" Caption="Category">
            <EditSettings>
                <DxComboBoxSettings Data="Categories"
                                    ValueFieldName="CategoryId"
                                    TextFieldName="CategoryName"/>
            </EditSettings>
        </DxGridDataColumn>
        <DxGridDataColumn FieldName="ProductName" />
        <DxGridDataColumn FieldName="UnitPrice" />
        <DxGridDataColumn FieldName="UnitsInStock" />
        <DxGridDataColumn FieldName="QuantityPerUnit" />
    </Columns>
</DxGrid>
@code {
    NorthwindContext Northwind { get; set; }
    List<Product> Products { get; set; }
    List<Category> Categories { get; set; }

    protected override async Task OnInitializedAsync() {
        Northwind = NorthwindContextFactory.CreateDbContext();
        Products = await Northwind.Products.ToListAsync();
        Categories = await Northwind.Categories.ToListAsync();
    }

    public void Dispose() {
        Northwind?.Dispose();
    }
}

To change the field that supplies values at runtime, use the IComboBoxSettings.ValueFieldName property.

Implements

See Also