Note that there are some explanatory texts on larger screens.

plurals
  1. POMVC Display Template not showing
    text
    copied!<p>I have a model called ComplaintModel:</p> <pre><code>public class ComplaintModel { private Data.MTAEntities db = new MTAEntities(); public IEnumerable&lt;Complaint&gt; Complaints { get; set; } public void GetAllComplaints() { var complaints = (from c in db.tbComplaints orderby c.CreateDateTime descending select new Complaint() { Comment = c.Complaint, ComplaintID = c.ComplaintID, CreateDateTime = c.CreateDateTime }); Complaints = complaints; } </code></pre> <p>On my index page I have the following code:</p> <pre><code>&lt;% Html.DisplayFor(m =&gt; Model.Complaints, "Complaint"); %&gt; </code></pre> <p>I am pretty much passing an IEnumerable object to my Display Template. In my display template:</p> <pre><code>&lt;%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl&lt;IEnumerable&lt;MTA.Models.Entities.Complaint&gt;&gt;" %&gt; &lt;%@ Import Namespace="MTA.Models.Entities" %&gt; &lt;% foreach (Complaint complaint in Model) { %&gt; &lt;div id="complaint"&gt; &lt;%:complaint.Comment%&gt; &lt;/div&gt; &lt;% }%&gt; </code></pre> <p>I definitely have one Complaint class in my collection, for some reason it is not displaying. Am I missing something? I also don't get any errors which makes it harder to figure out what I am doing wrong. Only thing I can think of its being lost before it gets to my Display Template somehow?</p> <p>Thank you!</p> <p>EDITS:</p> <p>The exact path to the user control is: ~/Views/Home/DisplayTemplates/Complaint.ascx</p> <p>The controller method call:</p> <pre><code>public ActionResult Index() { var model = new MTA.Models.ComplaintModel(); model.GetAllComplaints(); ViewData["model"] = model; return View(model); } </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload