p2p.wrox.com Forums

p2p.wrox.com Forums (http://p2p.wrox.com/index.php)
-   BOOK: Professional ASP.NET MVC 2 (http://p2p.wrox.com/forumdisplay.php?f=588)
-   -   NerdDinner: Index.aspx only displays last dinner entry (http://p2p.wrox.com/showthread.php?t=83951)

bbcc66 June 9th, 2011 06:32 AM

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()%>

        <% } %>


bbcc66 June 9th, 2011 06:46 AM

Please ignore the above. I realised that the dates in my dinners table where mostly past ones and that the file looks for upcoming dinners. Sorry!

All times are GMT -4. The time now is 06:33 AM.

Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.