In my class i have more attributes and all have the good value when i check after submit the form All variables are fine except the bool who is always false. Can someone help me? My class:
public class Pilot
{
.....
public bool OwnerOrPart { get; set; }
.....
}
My model:
public class IardModel : RepositoryCollection
{
.......
public List<Pilot> Pilot { get; set; }
.....
public IardModel()
{
.....
Pilot = new List<Pilot>();
.....
}
}
Controller:
public ActionResult Aeronef(IardModel model, string id)
{
if (id != "") {
using (var scope = RepositoryContainer.Container.BeginLifetimeScope())
{
var repository = scope.Resolve();
model = repository.SingleById(id);
model.IsEditing = true;
return View(model);
}
}
model.IsEditing = false;
return View(model);
}
And the view:
@if (Model.Pilot.Count == 0)
{
....
<section class="col col-md-2">
<label class="label-form">(Co)Propriétaire</label>
<label class="checkbox">
<input name="Pilot[0].OwnerOrPart" type="checkbox" class="form-control">
<i></i>
</label>
</section>
}
@foreach (var pilots in Model.Pilot)
{
....
<section class="col col-md-2">
<label class="label-form">(Co)Propriétaire</label>
<label class="checkbox">
<input name="Pilot[@(Model.Pilot.IndexOf(pilots))].OwnerOrPart" type="checkbox" class="form-control" @(pilots.OwnerOrPart ? "checked='checked'" : "")>
<i></i>
</label>
</section>
}
All variables are fine except the bool who is always false. Can someone help me