1

the @Html.RadioButtonFor always confuses me right now I have in a ViewModel a property of an enum(lets say DayOfWeek as it is built in)

public class VM
{
    public DayOfWeek  SelectedDayOfWeek { get; set; }
}

in my view I have

@Html.RadioButtonFor(x => x.Vm.SelectedDayOfWeek,false, new {@id = "Sun"})
@Html.RadioButtonFor(x => x.Vm.SelectedDayOfWeek,false, new {@id = "Mon"})  

Now this works but how do I get it to work for editing. For instance they want to edit the day of week they set. I want to show them which option they choose.

How could I do this. As you see right now it is hardcoded to false.

Don't really want to do this

   @Html.RadioButtonFor(x => x.Vm.SelectedDayOfWeek,@SelectedSunValue, new {@id = "Sun"})
    @Html.RadioButtonFor(x => x.Vm.SelectedDayOfWeek,@SelectedMonValue, new {@id = "Mon"})
chobo2
  • 83,322
  • 195
  • 530
  • 832
  • See selected answer here http://stackoverflow.com/questions/5621013/pass-enum-to-html-radiobuttonfor-mvc3?rq=1 – glosrob Oct 12 '12 at 21:22
  • you can also do it with client side jquery if you can update fine and the problem is just display – COLD TOLD Oct 12 '12 at 23:11

0 Answers0