0

I'm struggling binding values when using a FluentSelect. Can someone see what is wrong with the following?

<EditForm Model="..." OnValidSubmit="HandleValidSubmit">
...
<FluentSelect @bind-Value=@intValue TOption="int">
    <FluentOption Value=1>
        Option 1
    </FluentOption>
    <FluentOption Value=2>
        Option 2
    </FluentOption>
</FluentSelect>

-- Code behind --

int intValue;

protected async Task HandleValidSubmit()
{
    var i = intValue;
}

-- Edit --

How to two-way-bind a value in FluentListBox doesn't help me. It refers to the FluentListBox control, which apparently doesn't work with Forms.

Matt Fitzmaurice
  • 1,319
  • 4
  • 19
  • 40
  • Does this answer your question? [How to two-way-bind a value in FluentListBox](https://stackoverflow.com/questions/73497934/how-to-two-way-bind-a-value-in-fluentlistbox) – gdlmx Mar 03 '23 at 02:08
  • Try to use `@key` with you options ! – Nb777 Mar 03 '23 at 07:04

1 Answers1

0

You have

<FluentSelect @bind-Value=@intValue TOption="int">

int intValue;

but the Value property is always a string, not a TOption.

The basic fix:

string intValue;

protected async Task HandleValidSubmit()
{
    var i = int.Parse(intValue);
}
H H
  • 263,252
  • 30
  • 330
  • 514