I am new to MVC and am using MVC 3 and entity framework 4.1.
I have the following:
public ViewResult Index(string id)
{
return View(db.Documents.Where(r => r.DocNum == id).ToList());
}
This gives me a list of all records that contain the Document DocNum. The Document table also has a field TITLE. I want to place that TITLE into a ViewBag to use at the top of the returned View. How do I get Document.Title into a ViewBag?
I think you’re looking for:
Update
If you are returning the document to the view via:
Then in the view you can simply either (Assuming Razor):
Or if you are using a Razor Layout then..