Back to Devexpress

DxDropDownBox.ValueExpression Property

blazor-devexpress-dot-blazor-dot-dxdropdownbox-ef391f72.md

latest2.9 KB
Original Source

DxDropDownBox.ValueExpression Property

Specifies a lambda expression that identifies the Value property’s bound value when the editor is placed in the EditForm.

Namespace : DevExpress.Blazor

Assembly : DevExpress.Blazor.v25.2.dll

NuGet Package : DevExpress.Blazor

Declaration

csharp
[Parameter]
public Expression<Func<object>> ValueExpression { get; set; }

Property Value

TypeDescription
Expression<Func<Object>>

A lambda expression that identifies the bound value.

|

Remarks

The ValueExpression property obtains metadata about the value bound to the Value property. It is used when you add a DxDropDownBox to Blazor’s standard EditForm component to validate the Value property value.

You can set up this property in one of the following ways:

razor
<DxDropDownBox Value="@Value" 
               ValueExpression="@(() => Value)"
               ValueChanged="@((object newValue) => OnValueChanged(newValue))" ...>
    @* ... *@
</DxDropDownBox>

@code {
    object Value { get; set; }

    void OnValueChanged(object newValue) {
      Value = newValue;
      // ...
    }
}
  • Use the @bind attribute for the Value property to implement two-way binding. In this case, the ValueExpression property is set internally.
razor
<DxDropDownBox @bind-Value="Value" ... />

@code {
    object Value { get; set; }
    // ...
}

The following exception occurs if you do not use two-way binding or the ValueExpression property:

DevExpress.Blazor.DxDropDownBox requires a value for the ‘ValueExpression’ property. It is specified automatically when you use two-way binding (‘bind-Value’).

See Also

DxDropDownBox Class

DxDropDownBox Members

DevExpress.Blazor Namespace