I am trying to implement the "Work with radio buttons" example found at https://docs.microsoft.com/en-us/aspnet/core/blazor/forms-validation?view=aspnetcore-3.1#work-with-radio-buttons however I ran into difficulty when trying to use it with an enum.
@page "/RadioButtonExample"
@using System.ComponentModel.DataAnnotations
@using MyApp.Shared
<h1>Radio Button Group Test</h1>
<EditForm Model="model" OnValidSubmit="HandleValidSubmit">
<DataAnnotationsValidator />
<ValidationSummary />
@foreach (int status in Enum.GetValues(typeof(Status)))
{
<label>
<InputRadio name="rate" SelectedValue="status" @bind-Value="model.Status" />
@status
</label>
}
<button type="submit">Submit</button>
</EditForm>
<p>You chose: @model.Status</p>
@code {
private Administrator model = new Administrator();
private void HandleValidSubmit()
{
Console.WriteLine("valid");
}
}
My enum is defined as below
public enum Status
{
Disabled = 0,
Enabled = 1
}
The error I receive is the below which I understand why I'm getting, however, I'm not sure how best to resolve.
TypeInference.CreateInputRadio_0(RenderTreeBuilder, int, int, object, int, TValue, int, TValue, int, EventCallback, int, Expression>)' cannot be inferred from the usage. Try specifying the type arguments explicitly.
Any help much appreciated