所以使用这个例子来做一个复选框列表
它在我的创建(对于新注册)中工作正常,但在我的编辑中却没有,并且无法弄清楚为什么我的课程:
public class cliente
{
[Key ,DatabaseGenerated(DatabaseGeneratedOption.None)]
public int id { get; set; }
[DisplayName("Nombre")]
[Required(ErrorMessage = "Descripcion es requerido.")]
[MaxLength(100, ErrorMessage = "El Nombre no puede contener mas de 100 caracteres")]
public string descripcion {get; set;}
[DisplayName("Visita")]
public string visita { get; set; }
public Dias DiasVisita { get; set; }
//more properties..
[Flags]//<-- Note the Flags attribute
public enum Dias
{
Lunes = 1,
Martes = 2,
Miercoles = 4,
Jueves = 8,
Viernes = 16,
Sabado = 32,
Domingo = 64,
}
我的观点。
@using (Html.BeginForm()) {
@Html.ValidationSummary(true)
<fieldset>
<legend>Cliente</legend>
@Html.HiddenFor(model => model.id)
@Html.HiddenFor(model => model.categoria)
@Html.HiddenFor(model => model.visita)
<div class="editor-label">
@Html.LabelFor(model => model.descripcion)
</div>
<div class="editor-field">
@Html.TextBoxFor(model => model.descripcion, new { style = "width: 300px;" })
@Html.ValidationMessageFor(model => model.descripcion)
</div>
<div class="editor-label">
@Html.LabelFor(model => model.visita)
</div>
<div class="editor-field">
@Html.CheckboxListForEnum("dias", Model.DiasVisita)
</div>
<div class="editor-label">
@Html.LabelFor(model => model.orden)
</div>
<div class="editor-field">
@Html.TextBoxFor(model => model.orden)
@Html.ValidationMessageFor(model => model.orden)
</div>
<p>
<input type="submit" value="Guardar" />
</p>
</fieldset>
}
当我按下按钮调试时,控制器动作编辑器没有进入这里
[HttpPost]
public ActionResult Editar(cliente cliente, string[] dias)
{
}
当我按下按钮时,我怎么知道它去了哪里或它在寻找什么?奇怪的是,我的创作与这次编辑相同,但创作工作