@Html.RadioButtonFor
总是让我感到困惑我现在在ViewModel中有一个enum的属性(比如说内置的DayOfWeek)
public class VM
{
public DayOfWeek SelectedDayOfWeek { get; set; }
}
在我看来我有
@Html.RadioButtonFor(x => x.Vm.SelectedDayOfWeek,false, new {@id = "Sun"})
@Html.RadioButtonFor(x => x.Vm.SelectedDayOfWeek,false, new {@id = "Mon"})
现在这可行,但我如何让它用于编辑。例如,他们想要编辑他们设置的星期几。我想向他们展示他们选择的选项。
我怎么能这样做正如你现在所看到的,它被硬编码为假。
真的不想这样做
@Html.RadioButtonFor(x => x.Vm.SelectedDayOfWeek,@SelectedSunValue, new {@id = "Sun"})
@Html.RadioButtonFor(x => x.Vm.SelectedDayOfWeek,@SelectedMonValue, new {@id = "Mon"})