how to give value to model from radio button html asp with enums if checked
snippet in html

how to give value to model from radio button html asp with enums if checked

user4340

@model MvcTest.Models.Airlines
@foreach (var value in Enum.GetValues(typeof(MvcTest.Models.Airlines)))
{
    @Html.RadioButtonFor(m => m, value)
    @Html.Label(value.ToString())
}

how to give value to model from radio button html asp with enums if checked

user2544

public class TestModel
{
    [Required(ErrorMessage = "select one item")]
    public Airlines Airline { get; set; }
}

how to give value to model from radio button html asp with enums if checked

user6392

@model Enum
@foreach (var value in Enum.GetValues(Model.GetType()))
{
    @Html.RadioButtonFor(m => m, value)
    @Html.Label(value.ToString())
}