Hi
Compiler Error Message: CS1061: 'MyViewModel' does not contain a definition for 'Id' and no extension method 'Id' accepting a first argument of type 'MyViewModel' could be found (are you missing a using directive or an assembly reference?)
Source Error:
Line 23:
Line 24:
Line 25: @Html.DisplayNameFor(model => model.Id)
Line 26:
Line 27:
public ActionResult Index()
{
//MyViewModel lvm = new MyViewModel();
//lvm.Customers = dbCustomer.GetAllCustomer().ToList();
//lvm.Customer = new Customer();
//return View(lvm);
return View();
}
public JsonResult List()
{
MyViewModel lvm = new MyViewModel();
lvm.Customers = dbCustomer.GetAllCustomer().ToList();
lvm.Customer = new Customer();
return Json(lvm, JsonRequestBehavior.AllowGet);
//return Json(dbCustomer.GetAllCustomer().ToList(), JsonRequestBehavior.AllowGet);
}
@model MyApplication.Models.ViewModel.MyViewModel
Manage Customers
@Html.DisplayNameFor(model => model.Id) | @Html.DisplayNameFor(model => model.Description) | @Html.DisplayNameFor(model => model.IsActive) | Action |
|---|
3 Answers
Know the answer? Post it. Somebody with the same question will find it here.


Sachin SinghRank #66 · 26.2K reputationPosted Jun 18, 2021, 10:34 AM EDT