ERROR TYPE: Output false false false for @Html.EditorFor(model => model.Items)
Expected Result: Listbox with the name of users.
ViewModel
public class NewVariance
{
MVRLinqDataContext LinqCtx = new MVRLinqDataContext()
public NewVariance()
{
IndividualsObjectTest();//load data dropdown and listbox data
}
public MultiSelectList Items { get; set; }
//loads the values of the MultiSelectList above
public void IndividualsObjectTest()
{
var IndividualsDropDownList =
(
from x in LinqCtx.ViewIndividualDropDownBoxes
orderby x.FullName
select x);
Items = new MultiSelectList
(
IndividualsDropDownList as
System.Collections.IEnumerable, "First_Hospital_Case_Nbr", "FullName"
);
}
Controller
public class NewVarianceController : Controller
{
public ActionResult Index()
{
var model = new NewVariance();
return View(new model);
}
}
View
@Html.ListBox("d",Model.Items) THIS WORKS
@Html.EditorFor(model => model.Items) THIS DOESNT WORK OUTPUTS FALSE FALSE FALSE
An editor template simply renders some default output based on the property type. You need to personalize it if you expect to do something useful. You can read more about templated helpers on this blog post. You cannot expect that a default editor template would know that you want it to render a listbox for this given property. So you could write a custom editor template and personalize this behavior.