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 Replies
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.

Sachin SinghPosted Jun 18, 2021, 2:34 PM