Skip to main content

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

DxComboBox<TData, TValue>.TextExpression Property

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

Namespace: DevExpress.Blazor

Assembly: DevExpress.Blazor.v24.2.dll

NuGet Package: DevExpress.Blazor

#Declaration

C#
[Parameter]
public Expression<Func<string>> TextExpression { get; set; }

#Property Value

Type Description
Expression<Func<String>>

A lambda expression that identifies the bound value.

#Remarks

You can add a ComboBox to Blazor’s standard EditForm component to validate the Text property value. In this case, the TextExpression property is used to obtain metadata about the value bound to the Text property.

You should specify the TextExpression property if you handle the TextChanged event and cannot use two-way binding.

Razor
<EditForm>
    <DxComboBox Data="@Cities"
                TValue="string"
                TData="string"
                AllowUserInput="true"
                Text="@Text"
                TextChanged="@OnTextChanged"
                TextExpression="@(() => Text)">
    </DxComboBox>
</EditForm>

@code {
    IEnumerable<string> Cities = new List<string>() {
        "London",
        "Berlin",
        "Paris",
    };

    string Text { get; set; } = "New York";

    void OnTextChanged(string newValue) {
        Text = newValue;
    }
}

The TextExpression property is set internally if you use the @bind attribute for the Text property to implement two-way binding.

Razor
<EditForm>
    <DxComboBox Data="@Cities"
                TValue="string"
                TData="string"
                AllowUserInput="true"
                @bind-Text="@Text">
    </DxComboBox>
</EditForm>

@code {
    IEnumerable<string> Cities = new List<string>() {
        "London",
        "Berlin",
        "Paris",
    };

    string Text { get; set; } = "New York";

    void OnTextChanged(string newValue) {
        Text = newValue;
    }
}

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

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

See Also