I have a Blazor EditForm like this:
<EditForm Model="EntryModel" OnValidSubmit="HandleValidSubmit" @oninput="OnInput" >
//...other stuff...
@foreach (var v in EntryModel.VehiclePremiums)
{
<tr>
<td>@v.vehicleid</td>
<td>@v.vehicleMake</td>
<td>@v.vehicleModel</td>
<td><InputNumber @bind-Value="@v.premium" /></td>
</tr>
}
//...other stuff
</EditForm>
Now as the user types into the InputNumber field, I want to sum up the value on all these fields. So, in the OnInput function, I do this:
public void OnInput(){
total_premium = EntryModel.VehiclePremiums.Select(vp => vp.premium).Sum();
}
This gives me a form like this:

The problem is that when I enter premium for the first car, the total is not updated. When I enter for the second car, the total is updated but current value is not included. Kind of strange behavior. The sum is always one field behind.
How should I sum up these fields as the user types in (either while inputting or after losing focus, doesn't matter)?