如何修复链接表的呼叫部分视图

时间:2019-02-19 00:12:22

标签: asp.net-mvc-5

我试图显示带有相关注释的票证以显示在部分视图中,但是加载后我的票证页面为空白,没有任何错误

Internet上有太多关于局部视图的信息,我正在努力寻找树木茂盛的森林

TicketController:

   public ActionResult ViewTickets(int? TicketID)
    {

        HelpDeskDBContext db = new HelpDeskDBContext();

        List<CommentViewModel> ListComment = db.Comments.Where(x => x.IsDeleted == false && x.TicketID == TicketID).Select(x => new CommentViewModel { CommentDescription = x.CommentDescription, CommentDate = x.CommentDate, TicketID = x.TicketID }).ToList();


        return PartialView("_Comment");
    }

CommentViewModel:

      using ITHelpdesk.Areas.Support.Entities;
 using System;


namespace ITHelpdesk.Areas.Support.Models
  {
  public class CommentViewModel
   {

    public int TicketID { get; set; }
    public string Title { get; set; }
    public DateTime? TimeStamp { get; set; }
    public string Description { get; set; }
    public Nullable<bool> IsDeleted { get; set; }
    public int CommentID { get; set; }
    public int CommentOwnerID { get; set; }
    public DateTime? CommentDate { get; set; }
    public string CommentDescription { get; set; }
    public DateTime Date { get; internal set; }
    public int TicketOwnerID { get; set; }
    public int TicketStatusID { get; set; }
    public int TicketTypeID { get; set; }
    public int TicketPriorityID { get; set; }
    public virtual TicketOwner TicketOwner { get; set; }
    public virtual TicketStatus TicketStatus { get; set; }
    public virtual TicketPriority TicketPriority { get; set; }
    public virtual TicketType TicketType { get; set; }


     }
   }   

简要介绍一下ViewTicket:

@model ITHelpdesk.Areas.Support.Models.CommentViewModel
<link href="~/Content/flexbox.css" rel="stylesheet" type="text/css" />
@{
     ViewBag.Title = "Ticket";
 }

 <!-- /#breadcrumbs-->
 <div id="page-header-container">
    <div class="container">
      <div class="page-header row">
        <div class="span8">

        </div>
        <div class="span4">


          </div>
       </div>
    </div>
  </div>
 <!-- /#breadcrumbs-->

   <div id="wrap" class="container" role="document">
    <div id="content" class="row">
      <div id="main" class="span9" role="main">


        <div>

            <br />



            <article class="post-15 page type-page status-publish hentry" />

            <header>

                <h1 class="ticket-title">@Html.DisplayFor(model => model.Title)</h1>

            </header>

     @if (ViewBag.TicketList != null)
        {

            foreach (var item in ViewBag.TicketList)
            {
                <tr id="row_@item.CommentId">
                    <td>@item.CommentDate</td>
                    <td>@item.CommentDescription</td>
                </tr>

            }
        }

我希望可以看到故障单的摘要,其中包含基于TicketId的注释并按数据顺序进行了排序,尽管由于页面不会加载任何错误或数据,所以我没有设法对commentdate进行排序

0 个答案:

没有答案