如何在父模型中使用PagedList-ASP.NET MVC

时间:2018-07-26 12:03:26

标签: c# asp.net-mvc pagedlist

在我的ControllerView中,我使用了不同的Parent Modals;在Parent modals的其中一个Comment_List中,我想使用PagedList,并且正如您在Controller中看到的那样,我做到了,但是当涉及到View时,我感到困惑,我不知道是哪个ModalsMain或{{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>
  }

0 个答案:

没有答案