If I understand correctly you want to set the Id field. I think this is what you are after.
@page "/characters"
@using System.ComponentModel.DataAnnotations
@inject ILogger<Character> Logger
<h3>Characters</h3>
<EditForm Model="taskModel" OnValidSubmit="HandleSubmit" FormName="RomulanAle">
<DataAnnotationsValidator />
<ValidationSummary />
<div>
<InputNumber @bind-Value="taskModel.Id" class="form-control" />
</div>
<div>
<label for="name">Name</label>
<InputText @bind-Value="taskModel.Text" class="form-control" />
</div>
<br />
<button type="submit" class="btn btn-primary">Create Character</button>
</EditForm>
@code {
[SupplyParameterFromForm]
public TaskModel? taskModel { get; set; }
protected override async Task OnInitializedAsync()
{
taskModel ??= new() { Id = 5 };
}
private void HandleSubmit()
{
Logger.LogInformation("alla = {alla} ad = {ad}", taskModel.Text, taskModel.Id);
}
public class TaskModel
{
[Required]
public int? Id { get; set; }
[Required]
public string? Text { get; set; }
}
}
The official documentation illustrates how to do handle binding forms in Blazor. ASP.NET Core Blazor forms binding