加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 编程开发 > asp.Net > 正文

asp.net-mvc – 模型绑定复选框问题列表

发布时间:2020-12-16 03:33:59 所属栏目:asp.Net 来源:网络整理
导读:在我的EditorTemplates中,我有两个视图.一个为我的类别(称为_Category) @model com.example.Models._Category@Html.CheckBox(Model.Name,Model.Selected)@Html.LabelFor(c = c.Name,Model.Name)br / 和一个类别列表(称为_Categories) @model Listcom.example
在我的EditorTemplates中,我有两个视图.一个为我的类别(称为_Category)

@model com.example.Models._Category
@Html.CheckBox(Model.Name,Model.Selected)
@Html.LabelFor(c => c.Name,Model.Name)
<br />

和一个类别列表(称为_Categories)

@model List<com.example.Models._Category>
@for (int i = 0; i < Model.Count; i++)
{
    @Html.EditorFor(c => Model[i]);
}

在显示这些类别的视图中,我有一个正在使用的类别列表,如下所示:

@Html.EditorFor(m => m.Categories,"_Categories")

当我查看页面时,旁边有多个带有名称的checbox,这很好.复选框的名称不太好,但结果看起来像这样:

….名称= “类别[1] .Batman” ….“>

名称中有一个额外的点需要消失.有想法该怎么解决这个吗?

提前致谢

解决方法

对于集合数据绑定,请参考 this和 this,这是两个最终资源.

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读