M005
M005

Reputation: 854

Issue in Display template mvc4

I am new in MVC. I have tried to read online articles about how to use display template in collection.

This is my Model

public class InsuranceListViewModel
{
    public IList<InsuranceViewModel> InsuranceViewModelList { get; set; }
    public InsuranceViewModel InsuranceViewModel { get; set; }
    public List<InsuranceSummaryViewModel> InsuranceSummaryViewModelList { get; set; }
}

SummaryViewModel

 public class InsuranceSummaryViewModel
{
    public string FriendlyName { get; set; }
    public int InsuranceId { get; set; }
    public string GroupId { get; set; }
    public string MemberId { get; set; }
    public Nullable<System.DateTime> PolicyStartDate { get; set; }
    public Nullable<System.DateTime> PolicyEndDate { get; set; }

}

InsurnaceDisplay.cshtml

@model P2PExchange.MVC.Web.Areas.Patient.Models.InsuranceSummaryViewModel
@Html.DisplayFor(x => x.InsuranceId)
@Html.DisplayFor(x => x.FriendlyName)
@Html.DisplayFor(x => x.GroupId)
@Html.DisplayFor(x => x.MemberId)
@Html.DisplayFor(x => x.PolicyStartDate)
@Html.DisplayFor(x => x.PolicyEndDate)

_Insurance.cshml

 @model Models.InsuranceListViewModel
 @Html.DisplayFor(x=>x.InsuranceSummaryViewModelList)

My above code it only displays insurance friendly name not all fields from display template.

Can someone please help/guide me how Can I display correct data on UI?

Upvotes: 1

Views: 26

Answers (1)

user3559349
user3559349

Reputation:

Your DisplayTemplate needs to be located in the /Views/Shared/DisplayTemplates or /Views/yourControllerName/DisplayTemplates folder and needs to be named to match the name of the class, i.e. InsuranceSummaryViewModel.cshtml

Upvotes: 1

Related Questions