Hi I have a model that contains an enum called activitylevel and also a property called activityselected, I have a table of radiobuttons that are bound to the activityselected property, when a radiobutton is select I want to pass the corresponding enum to the activityselected property, in我的观点是“当前上下文中不存在 ActivityLevel”?只是想知道我出错了还是有更好的方法?谢谢您的帮助!!
模型:
public class UserStats
{
public enum ActivityLevel
{
Sedentary,
LightActivity,
Moderate,
Active,
Extra
}
public Enum ActivitySelected { get; set; }
[Key]
public int UserID { get; set; }
看法:
<table>
<tr>
<td>
@Html.RadioButtonFor(model => model.ActivitySelected, ActivityLevel.Sedentary) Sedentary
</td>
</tr>
<tr>
<td>
@Html.RadioButtonFor(model => model.ActivitySelected,ActivityLevel.LightActivity) Light Activity
</td>
</tr>
<tr>
<td>
@Html.RadioButtonFor(model => model.ActivitySelected, ActivityLevel.Moderate) Moderate
</td>
</tr>
<tr>
<td>
@Html.RadioButtonFor(model => model.ActivitySelected,ActivityLevel.Active) Active
</td>
</tr>
<tr>
<td>
@Html.RadioButtonFor(model => model.ActivitySelected, ActivityLevel.Extra) Extra
</td>
</tr>
</table>