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
本文作者: