Skip to main content
A newer version of this page is available. .

DxComboBox<TData, TValue>.Value Property

Specifies the ComboBox’s selected value/item.

Namespace: DevExpress.Blazor

Assembly: DevExpress.Blazor.v20.2.dll

NuGet Package: DevExpress.Blazor

Declaration

[Parameter]
public TValue Value { get; set; }

Property Value

Type Description
TValue

The value type.

Remarks

Use the Value property to access to the ComboBox’s selected value or item. To respond to changes, handle the ValueChanged event.

The Value property can return the following objects:

  • If the ValueFieldName property is specified, the Value property returns the selected item’s value.
  • If the ValueFieldName property is not specified, the Value property returns the selected item.

The example below demonstrates how to populate a ComboBox editor with items based on another ComboBox’s selection.

ComboBox Cascade Logic

<DxComboBox Data="@Countries"
            TextFieldName="@nameof(Country.CountryName)"
            Value="@CurrentCountry"
            ValueChanged="@((Country country) => SelectedCountryChanged(country))">
</DxComboBox>
<DxComboBox Data="@CurrentCountryCities"
            TextFieldName="@nameof(City.CityName)"
            @bind-Value="@CurrentCity">
</DxComboBox>

@code {
    List<Country> Countries { get; set; } = CountryCity.Countries;
    List<City> CurrentCountryCities { get; set; } = new List<City>();
    Country CurrentCountry { get; set; } = CountryCity.Countries[1];
    City CurrentCity { get; set; } = CountryCity.Cities[4];

    protected override void OnInitialized() {
        base.OnInitialized();
        SelectedCountryChanged(CurrentCountry);
    }

    void SelectedCountryChanged(Country country) {
        CurrentCountry = country;
        CurrentCountryCities = CountryCity.Cities.FindAll(city => city.CountryId == CurrentCountry.Id);
        CurrentCity = CurrentCountryCities[0];
    }
}

Run Demo: ComboBox - Cascading Lists

See Also