I have a FK in my Details ViewModel and when the View binds to the ViewModel I only get the FK back (expected). The FK is a reference to a simple ID/Name type table. I also have a Strongly typed List in the VM representing that FK-referenced table. I want to do something like
<div class="display-field">@Model.ManufacturersList.Find(x => x.ID == Model.softwaremanufacturerid))</div>
While this will return the the instance I want…I can’t figure out how to get the “Name” attribute to display.
Sorry if this is more a Lamda question but thought I’d try all the same
Thanks
If
.ManufacturersList.Find(x => x.ID == Model.softwaremanufacturerid)returns what you want, don’t do it in the View. The View should only display data, while the model layer should really be doing the searching (.Find)In your view model, add a string property for
ManufacturerNameIn your controller,
Then in your view,
OR, more simply, you could use the ViewBag
Then in your View,