I'm trying to learn to use the ASP.Net MVC. I've been following the tutorials, which are great, but I've bumped into a problem that I'm hoping someone can help me with.
Function Index()
Dim dataContext = New PATSimDataContext()
Dim deletedvisits = From v In dataContext.VisitAudits Select v
Return View(deletedvisits)
End Function
Thats the Index function in my controller.
Here's my View:
<%@ Page Language="VB" MasterPageFile="~/Views/Shared/Site.Master" AutoEventWireup="false" CodeBehind="Index.aspx.vb" Inherits="PATSimRestore.Index" %>
<%@ Import Namespace="PATSimRestore" %>
<asp:Content ID="indexContent" ContentPlaceHolderID="MainContent" runat="server">
<ul>
<% For Each v As VisitAudit In ViewData.deletedvisits%>
<li><%v.VisitDate%></li>
<% Next%>
</ul>
</asp:Content>
But I get his error when I try to build this project:
'deletedvisits' is not a member of 'System.Web.Mvc.ViewDataDictionary'.
Can someone shed some light on what I need to do to fix this?
dbuttric
0 Points
1 Post
ASP.Net MVC ViewData collection does not contain my object
Oct 22, 2008 06:25 PM|LINK
Hi,
I'm trying to learn to use the ASP.Net MVC. I've been following the tutorials, which are great, but I've bumped into a problem that I'm hoping someone can help me with.
Function Index()
Dim dataContext = New PATSimDataContext()
Dim deletedvisits = From v In dataContext.VisitAudits Select v
Return View(deletedvisits)
End Function
Thats the Index function in my controller.
Here's my View:
<%@ Page Language="VB" MasterPageFile="~/Views/Shared/Site.Master" AutoEventWireup="false" CodeBehind="Index.aspx.vb" Inherits="PATSimRestore.Index" %>
<%@ Import Namespace="PATSimRestore" %>
<asp:Content ID="indexContent" ContentPlaceHolderID="MainContent" runat="server">
<ul>
<% For Each v As VisitAudit In ViewData.deletedvisits%>
<li><%v.VisitDate%></li>
<% Next%>
</ul>
</asp:Content>
But I get his error when I try to build this project:
'deletedvisits' is not a member of 'System.Web.Mvc.ViewDataDictionary'.
Can someone shed some light on what I need to do to fix this?
Thanks.
David Buttrick