I have a list that I return as part of a model. I want to be have each item in the list to appear on its own line. I have two approaches, neither of which quite do the job.
One way is to use a foreach(), which would allow me to use a break or whatever in each item. But to do that I have to make the model IEnumerable (or at least I think that's what I have to do), and I don't want to do that.
If I make it a regular model, though, a foreach() doesn't work. Can anyone guide me to a solution?
This is what I mean by a "regular model" (I'm too much of a noob to know the correct term)
@model AcademicAdvising.Models.AppointmentModel
Here's the list from the model itself
public List<string> ReferralTypeNames { get; set; }
And here's the line as it stands right now in the view:
<p>@Html.DisplayFor(model => model.ReferralTypeNames)</p>
That works, but there are no line breaks between items.
UPDATE
Here's a sample of what I want:
Academic Department
Academic Enhancement-Tutorial
Admissions
Another Academic Advisor
And here's a sample of what I get: Academic DepartmentAcademic Enhancement-TutorialAdmissionsAnother Academic Advisor
Here is the code for the rest of the form:
<table class="table-appt">
<tr>
<th>Student ID</th>
<td>@ViewBag.CurrentStudentId</td>
</tr>
<tr>
<th>Username</th>
<td>@ViewBag.CurrentStudentUsername</td>
</tr>
<tr>
<th>Name</th>
<td>@ViewBag.LName</td>
</tr>
<tr>
<th>Assigned Advisor</th>
<td>@Html.DisplayFor(model => model.AdvisorName)</td>
</tr>
<tr>
<th>Declared Major</th>
<td>@Html.DisplayFor(model => model.Major)</td>
</tr>
</table>
<fieldset>
<legend></legend>
<div class="field">
<h4>View a Different Advising Session</h4>
<div>
@Html.DisplayFor(model => model.AppointmentDates)
</div>
</div>
<div class="field">
<h3>Advisor</h3>
(person conducting appointment)<br />
<div>(name) @Html.DisplayFor(model => model.AdvisorId)</div>
</div>
<div class="field">
<h3>Contact/Appointment Type</h3>
<div>@Html.DisplayFor(model => model.ContactTypeName)</div>
</div>
<div class="field">
<h3>Appointment Notes</h3>
<div class="display-field">
@Html.DisplayFor(model => model.Notes)
</div>
</div>
<div class="field">
<h3>Advising Topics</h3>
<div>@Html.DisplayFor(model => model.AdvisingTopicNames)</div>
</div>
<div class="field">
<h3>Referral Topics</h3>
@Html.DisplayFor(model => model.ReferralTypeNames)<br />
</div>
</fieldset>