I'm doing this
using (var db = new MyContext())
{
var g = new MyGroup
{
Caracteristicas = db.Caracteristicas.ToList()
};
return View(g);
}
and getting this exception when trying to display that data:
The ObjectContext instance has been disposed and can no longer be used for operations that require a connection.
View:
@Html.EditorFor(m => m.Caracteristicas)
Custom editor:
@model Exemplo.Models.Caracteristica
<label class="checkbox">@Html.CheckBoxFor(m => m.Valor) @Model.Nome</label>
SOLVED (in part)
The problem was that I mismatched the name of the custom editor file.
But now that this little mistake is fixed, however, all Id
s (in bind) are zero... how to solve that? :(
This is the output:
<label class="checkbox">
<input data-val="true" data-val-required="The Valor field is required." id="Caracteristicas_0__Valor" name="Caracteristicas[0].Valor" type="checkbox" value="true" />
<input name="Caracteristicas[0].Valor" type="hidden" value="false" />
OldItem</label>
"value" shouldn't be the Id? :(