When we are in a InputRadioGroup, how to have a radio button checked by default? This does not seem to work:
<InputRadio class="mr-1" Name="Selected" Value="@("General")" checked="checked"></InputRadio>
The value of the @bind-Value="@_model.SelectedManufacturer" in the InputRadioGroup sets the value of the group and the code below will set the selected radio button to tesla at the start as that is what it is set to in the FormClass
<EditForm Model="_model">
<InputRadioGroup @bind-Value="@_model.SelectedManufacturer">
Manufacturer:
<br>
@foreach (var manufacturer in Manufacturers)
{
<InputRadio Value="manufacturer" />
@manufacturer
<br>
}
</InputRadioGroup>
</EditForm>
@code {
List<String> Manufacturers = new List<string> { "Ford", "Toyota", "Tesla" };
FormClass _model = new FormClass();
class FormClass
{
public String SelectedManufacturer { get; set; } = "Tesla";
}
}