Home > Mobile >  Dynamic Data On Blazorise Modal - Blazor
Dynamic Data On Blazorise Modal - Blazor

Time:12-24

Im Using Blazorise on a Blazor Page (Server-Side), and in the modal im working with:

@bind-Value="@myVariable" // @bind-SelectedValue="@myVariable"

And when i want to use myVariable on the following fields for a calculate calling a method, my variable never updates. Example

<Field>
    <FieldLabel>Calculate</FieldLabel>
        <Select TValue="float" @bind-SelectedValue="@myVariable">
            <SelectItem Value="7">7</SelectItem>
            <SelectItem Value="21">21</SelectItem>
        </Select>
</Field>

Then when i want to use myVariable it doesn't get the value (7 or 21)

What can i do, when i change the "myVariable" to set the new value

CodePudding user response:

Check This

<Field>
    <FieldLabel>Calculate</FieldLabel>
    <Select TValue="float" SelectedValue="@myVariable" SelectedValueChanged="@OnSelectedVariableChanged" >
        <SelectItem Value="0">0</SelectItem>
        <SelectItem Value="21">21</SelectItem>
    </Select>
</Field>

Then in Code do the following:

@code{
Task OnSelectedVariableChanged (float value)
{
    myVariable = value;
    return Task.CompletedTask;
}
}

That should Work as "dynamic value" setting it manually the new value when it change

  • Related