Hello,
I've run into a problem with the index.aspx file. It appears to be written out just like in the book, but it displays only the final item in my Dinners table. I have five items altogether in the table.
To see if it was an issue with the loop I removed the fifth/final dinner from the dinners table to see if it would instead display the fourth one. Instead it came up blank. Navigating to individual dinners is fine (e.g. .../dinners/details/3).
Here is the aspx file, hope someone can point out the issue with it, or where else I may have gone wrong. Thanks.
EDIT - Just to mention, this is from pages 51-53 of the book.
Code:
<%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage<IEnumerable<NerdDinner.Models.Dinner>>" %>
<asp:Content ID="Content1" ContentPlaceHolderID="TitleContent" runat="server">
Index
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
<h2>Upcoming Dinners</h2>
<ul>
<% foreach (var dinner in Model)
{ %>
<li>
<%: dinner.Title%>
on
<%: dinner.EventDate.ToShortDateString()%>
@
<%: dinner.EventDate.ToShortTimeString()%>
</li>
<% } %>
</ul>
</asp:Content>