所以我有这样的看法:
@model Tuple<LocApp.Models.Location, LocApp.Models.Service>
@{
ViewBag.Title = "Create";
}
<h2>Create</h2>
<script src="@Url.Content("~/Scripts/jquery.validate.min.js")" type="text/javascript"></script>
<script src="@Url.Content("~/Scripts/jquery.validate.unobtrusive.min.js")" type="text/javascript"></script>
@using (Html.BeginForm()) {
@Html.ValidationSummary(true)
<fieldset>
<legend>Location</legend>
<div class="editor-label">
@Html.LabelFor(model => model.Item1.name)
</div>
<div class="editor-field">
@Html.EditorFor(model => model.Item1.name)
@Html.ValidationMessageFor(model => model.Item1.name)
</div>
<div class="editor-label">
@Html.LabelFor(model => model.Item1.active)
</div>
<div class="editor-field">
@Html.EditorFor(model => model.Item1.active)
@Html.ValidationMessageFor(model => model.Item1.active)
</div>
@Html.CheckBoxFor(model => model.Item2.id)
<p>
<input type="submit" value="Create" />
</p>
</fieldset>
}
<div>
@Html.ActionLink("Back to List", "Index")
</div>
和行:@Html.CheckBoxFor(model => model.Item2.id)
IMO 应该通过,并且为数据库中的每个服务创建一个基于 id 的复选框,这样我就可以保存 id。但是,显然我必须传入一个布尔值?我只有一个model.Item2.active
想法?