Nemexia
0
Q:

how to fill model enum with bradio button asp razor

namespace Models
{
    public enum numbers
    {
        one = 1,
        two = 2,
        three = 3
    }
}
0
@{var numList = Enum.GetValues(typeof(Models.numbers));}
@foreach (object radiotext in numList)
{
    @Html.RadioButton("radioname", radiotext.ToString())@radiotext.ToString()
}
0
@model Enum
@foreach (var value in Enum.GetValues(Model.GetType()))
{
    @Html.RadioButtonFor(m => m, value)
    @Html.Label(value.ToString())
}
0
public class TestModel
{
    [Required(ErrorMessage = "select one item")]
    public Airlines Airline { get; set; }
}
0

New to Communities?

Join the community