View:
<%=Html.CheckBox("IsBirthday","我是否过生日", item.IsBirthday)%>
Controller:
AUser user = new AUser();
BindingHelperExtensions.UpdateFrom(user, Request.Form);
Model:
public class AUser{
public bool IsBirthday{get;set;}
}
这样会发生无法从View中获取到IsBirthday值的情况
查了许多MS只能以以下方法解决
Controller:
AUser user = new AUser();
BindingHelperExtensions.UpdateFrom(user, Request.Form);
user.IsBirthday= Request.Form["IsBirthday"]=="true";
View:
<%=Html.CheckBox("IsBirthday","我是否过生日","true", item.IsBirthday)%>
Over
同是学习,如果大家发现其它Bug欢迎交流.
时间: 2024-09-28 03:29:19