enum asp core radio button code example
Example 1: how to give value to model from radio button html asp with enums if checked
@model MvcTest.Models.Airlines
@foreach (var value in Enum.GetValues(typeof(MvcTest.Models.Airlines)))
{
@Html.RadioButtonFor(m => m, value)
@Html.Label(value.ToString())
}
Example 2: how to give value to model from radio button html asp with enums if checked
public class TestModel
{
[Required(ErrorMessage = "select one item")]
public Airlines Airline { get; set; }
}