View Single Post
  #1 (permalink)  
Old June 9th, 2011, 06:32 AM
bbcc66 bbcc66 is offline
Registered User
Join Date: Jun 2011
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default NerdDinner: Index.aspx only displays last dinner entry


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.

<%@ 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">

<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">

    <h2>Upcoming Dinners</h2>

        <% foreach (var dinner in Model)
           { %>

            <%: dinner.Title%>
            <%: dinner.EventDate.ToShortDateString()%>
            <%: dinner.EventDate.ToShortTimeString()%>

        <% } %>


Last edited by bbcc66; June 9th, 2011 at 06:38 AM.. Reason: left out info