在我的Controller
和View
中,我使用了不同的Parent Modals
;在Parent modals
的其中一个Comment_List
中,我想使用PagedList
,并且正如您在Controller
中看到的那样,我做到了,但是当涉及到View
时,我感到困惑,我不知道是哪个Modals
(Main
或{{1} })应该放在Parent
中。
型号:
IPagedList
查看:
public class VMRMA
{
public List<Comment_List> Comment_Lists { get; set; }
public class Comment_List
{
public Comment_List(string PM, int? ID , string writer)
{
this.PM = PM;
this.ID = ID;
this.writer = writer;
}
public int? ID { get; set; }
public string PM { get; set; }
public string writer { get; set; }
}
public HRMA HRMAs { get; set; }
public class HRMA
{
public HRMA(int Id,string Kundenavn)
{
this.Id = Id;
this.Kundenavn = Kundenavn;
}
public int Id { get; set; }
public string Kundenavn { get; set; }
}
}
控制器:
@using ModelNameSpace.Models
@model VMRMA
//single
<input type="text" class="form-control disabled" value="@Model.HRMAs.Kundenavn">
//List
@foreach (var item in Model.Comment_Lists)
{
<div class="card-body no-padding">
<div class="item d-flex align-items-center">
<div class="text">
<h3 class="h5">@item.PM</h3>
<small>Til @item.writer</small>
</div>
</div>
</div>
}