当我们使用CheckBoxFor类型需要使用bool ,可以将 int转换成bool

               <div class="form-group">
<label class="col-md-3 control-label">选项</label>
<div class="col-md-4">
@Html.CheckBoxFor(m => m.EnabledValue) 有效
@Html.CheckBoxFor(m => m.IsUnfoldValue) 展开
@Html.CheckBoxFor(m => m.AllowEditValue) 允许编辑
@Html.CheckBoxFor(m => m.AllowDeleteValue) 允许删除
<span class="help-block">
</span>
</div>
</div>

在实体类添加紫色代码

        /// <summary>
/// 有效:1-有效,0-无效
/// </summary>
public int? Enabled
{
set{ _enabled=value;}
get{return _enabled;}
}
public bool EnabledValue
{
get { return Enabled == ; }
set { Enabled = value ? : ; }
}

修改数据

  public ActionResult Edit(string id)
{
ViewBag.ControllerName = RouteData.Values["controller"].ToString().ToLower();
var model = new SAS.Model.BPMS_SysMenu();
model=bll.GetModel(id);
if (model != null)
{
ParentDropDownList();
return View(model);
}
else
{
return View("");
}
} [HttpPost, ValidateInput(false)]
public ActionResult Edit(string id, FormCollection fc)
{
var model = bll.GetModel(id);
if (model != null)
{ UpdateModel(model); //修改数据
bll.Update(model);
return RedirectToAction("ModuleList");
}
else
return View("");
}

数据库里面

1-有效,0-无效

使用效果比较好

ASP.NET MVC CheckBoxFor的int to bool的更多相关文章

  1. ASP.NET MVC CheckBoxFor为什么会生成hidden input控件

    自己开发的公众号,可以领取淘宝内部优惠券 @Html.CheckBoxFor(m => m.Bool) 使用CheckBoxFor方法得到的html代码会是下面这个样子 <input ch ...

  2. asp.net MVC Model 类的主键 int类型、string类型、GUID类型。

    在使用asp.net mvc进行定义 模型类的时候,一般情况下,我们都会定义一个属性为 int iD{get;set;} 或为int ClassNameID {get;set;},在这种情况下 1.I ...

  3. SignalR + KnockoutJS + ASP.NET MVC 实现井字游戏

    SignalR + KnockoutJS + ASP.NET MVC 实现井字游戏   1.1.1 摘要 今天,我们将使用SignalR + KnockoutJS + ASP.NET MVC实现一个实 ...

  4. Forms Authentication in ASP.NET MVC 4

    原文:Forms Authentication in ASP.NET MVC 4 Contents: Introduction Implement a custom membership provid ...

  5. ASP.NET MVC 入门

    ASP.NET MVC 入门 (Learning ASP.NET MVC) 传统的WebForm发展到如今出现不少的缺陷, 比如为了解决Http的无状态WebForm模式使用了ViewsState来保 ...

  6. ASP.NET MVC 4 (六) 帮助函数

    帮助函数封装一些代码,方便我们在应用程序中重用,MVC内建很多帮助函数,可以很方便的生成HTML标记.首先列出后面示例中用到的数据模型类定义: namespace HelperMethods.Mode ...

  7. Asp.net MVC 传递数据 从前台到后台,包括单个对象,多个对象,集合

    今天为大家分享下 Asp.net MVC 将数据从前台传递到后台的几种方式. 环境:VS2013,MVC5.0框架 1.基本数据类型 我们常见有传递 int, string, bool, double ...

  8. 使用Metrics.NET 构建 ASP.NET MVC 应用程序的性能指标

    通常我们需要监测ASP.NET MVC 或 Web API 的应用程序的性能时,通常采用的是自定义性能计数器,性能计数器会引发无休止的运维问题(损坏的计数器.权限问题等).这篇文章向你介绍一个新的替代 ...

  9. ASP.NET MVC 视图(五)

    ASP.NET MVC 视图(五) 前言 上篇讲解了视图中的分段概念.和分部视图的使用,本篇将会对Razor的基础语法简洁的说明一下,前面的很多篇幅中都有涉及到视图的调用,其中用了很多视图辅助器,也就 ...

随机推荐

  1. 【VBA】制作散点图及打标签VBA

    1.散点图的制作必须只选择xy轴对应的数据,不能选中标签. 2.调整xy轴交叉点,改为四个象限. 3.通过菜单移动散点图到新表. 4.运行宏,打上文本标签. VBA如下 Sub AttachLabel ...

  2. VC++ 在Watch窗口显示GetLastError值以及详细信息

    You can display the value GetLastError() will return by putting "@err" in your watch windo ...

  3. 【链接】LINUX SHELL脚本攻略笔记[速查]

    LINUX SHELL脚本攻略笔记[速查]

  4. Python_selenium之窗口切换(二)

    Python_selenium之窗口切换(二)一.思路拆分1. 之前有介绍窗口切换,这里加上断言部分2. 这里还是以百度新闻为例,获取百度新闻网址http://news.baidu.com/3. 同样 ...

  5. Linux 系统时间设置

    from:https://blog.csdn.net/yjh314/article/details/51669238 今早看到一台机器时间对不上,本以为系统时间与网络北京时间不同步,就在终端命令执行网 ...

  6. "_dns_free_resource_record", referenced from:问题

    本文转载至 http://blog.csdn.net/woaifen3344/article/details/41309471 _dns_free_resource_r_dns_free环信SDK集成 ...

  7. 【bzoj4518】[Sdoi2016]征途 斜率优化dp

    原文地址:http://www.cnblogs.com/GXZlegend/p/6812435.html 题目描述 Pine开始了从S地到T地的征途. 从S地到T地的路可以划分成n段,相邻两段路的分界 ...

  8. [LintCode] 尾部的零

    class Solution { public: // param n : description of n // return: description of return long long tr ...

  9. Jmeter--正则表达式提取值

    博客首页:http://www.cnblogs.com/fqfanqi/ 设置界面如下: Apply to:应用范围的选择: Field to check:检查的领域,即需要提取内容的地方. 下面是各 ...

  10. delphi -----TListView的用法

    层次关系: TListView:           ->Columns:           ->Items  : -->TListItems:                   ...