I am following a simple ADO.NET Entity/MVC 2 tutorial wherein my Views are created by right-clicking the action and selecting 'Add View'. The views get created based on my model and all is good. I can view the initial list of items from the DB but when I click Edit or Delete or Details I get 'Object reference not set to an instance of an object'. It acts like my data is not there at all so I'm thinking I may need to fill ViewData again?
Here is how I am getting the data:
CheckingEntities chk = new CheckingEntities();
//
// GET: /CheckingMVC/
[Authorize]
public ActionResult Index()
{
ViewData.Model = chk.tblCheckings.ToList();
return View();
}
And here is an example where I am getting the details:
// GET: /CheckingMVC/Details/5
[Authorize]
public ActionResult Details(int id)
{
return View();
}
I suspect I have filled the ViewData incorrectly or need to do it again but don't know where or how to do that. Still quite new to MVC.