I'm building an ASP.NET 4.5 MVC Web Application with partial views and a nested view model.
The problem: the view model is intially null... I need to create an input for SwotPartVm.Label and should put no logic in the View.
Do you have any suggests on how to solve this issue ?
Thanks :)
index.cshtml:
@foreach (var swot in Model.Swots)
{
foreach (var swotPart in swot.SwotParts)
{
@Html.Partial("~/Views/Shared/_SwotPart.cshtml", swotPart)
}
}
viewmodels: I need to create an input for SwotPartVm.Label...
public class OfferVM
{
public int OfferId { get; set; }
public List<SWOTVM> Swots { get; set; }
}
public class SWOTVM
{
// enum
public SwotFor SwotForId { get; set; }
public List<SwotPartVm> SwotParts { get; set; }
}
public class SwotPartVm
{
public string Label { get; set; }
// enum
public SwotType SwotTypeId { get; set; }
}