显示从mvc中的db值检查的复选框 [英] show checkbox checked from db values in mvc

查看:52
本文介绍了显示从mvc中的db值检查的复选框的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个checkboxList,它是从Property表中检索的。

在保存产品中,我保存了产品表中checkboxList的选中。

编辑产品页面,我希望根据db值检查此复选框列表。

I have a checkboxList which is retrieve from the table of Property.
In save products, I have saved the checked of checkboxList in Product Table.
In edit products page, I want this checkbox list to be checked depending on the db values.

推荐答案

检查出来: ASP.Net MVC-如何实现CheckBoxList? [ ^ ]


public class CheckBoxItem
{
   public string Code { get; set; }
   public bool IsChecked { get; set; }
   public string Label {get;set;}
}



razor:


razor:

<p class="checkbox" style="display:inline">
<span style="margin-left:5px;">
    @Html.HiddenFor(x => x.Code)           
    @Html.CheckBoxFor(x => x.IsChecked)
</span>
@Html.LabelFor(x => x.IsChecked, Model.Label)
</p>





请参阅参考号。

输入选中的复选框无法在MVC和Razor中使用 [ ^ ]

http://stackoverflow.com/questions/9973977/asp- net-mvc-3-retrieve-checkbox-list-values [ ^ ]


这篇关于显示从mvc中的db值检查的复选框的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆