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
 
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>


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 03:48 PM.

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