I want to pass an object Model.AvailableVerticalType
along with the
expression
and templateName
in the call to the HTML Helper DisplayFor
.
Without passing the object, the DisplayFor()
syntax looks like this:
@Html.DisplayFor(o => offer, MVC.Shared.Views.DisplayTemplates.OfferDetail)
The OfferDetail
template accepts an object of the type Offer
only:
@model DGS.DGSAPI.UI.BusinessModels.Offer
So I need a way to send the AvailableVerticleType
through the ViewData
. Is it possible? What would be the syntax for passing ViewData
in DisplayFor()
?
ViewBag
ofViewData
in the GET method? Note that its this overload that you want – DespoticModel.AvailableVerticalType
is part of the model – Plerre@Html.DisplayFor(o => offer, MVC.Shared.Views.DisplayTemplates.OfferDetail, new { data = Model.AvailableVerticalType } )
and then in the template you can access it using(yourType)ViewData["data"]
– Despotic