Reputation: 1850
The error I get is:
The type or namespace name 'LastSundayDate' could not be found (are you missing a using directive or an assembly reference?)
Here is my view code:
<%@ Page Title="" Language="C#" MasterPageFile="~/Views/Report/Report.Master" Inherits="System.Web.Mvc.ViewPage<IEnumerable<LastSundayDate>>" %>
<asp:Content ID="Content1" ContentPlaceHolderID="TitleContent" runat="server">
Trade Searches Data
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
<h2>TradeUK KPI Searches Data</h2>
<p></p>
Then I have:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace TradeUK.Entities.Reporting
{
public class LastSundayDate
{
public virtual int Title { get; set; }
public virtual int Total { get; set; }
public virtual int Week6 { get; set; }
public virtual int Week5 { get; set; }
public virtual int Week4 { get; set; }
public virtual int Week3 { get; set; }
public virtual int Week2 { get; set; }
public virtual int Week1 { get; set; }
}
}
In my controller I have:
public ActionResult TradeUKKPIShowData(DateTime date) //show actual data in the view
{
var reportData = _reportingService.GetTradeUKKPISearches(date);
return View(reportData);
}
Upvotes: 0
Views: 445
Reputation: 218952
Include the Namespace of your class. Otherwise your program can not understand where is this LastSundayDate
class is present in.
Change
Inherits="System.Web.Mvc.ViewPage<IEnumerable<LastSundayDate>>
to
Inherits="System.Web.Mvc.ViewPage<IEnumerable<
TradeUK.Entities.Reporting.LastSundayDate>>
Alternatively, You can also Import the namespace to the View.Add this line in your view, above the Page
directive declaration
<%@ Import Namespace="TradeUK.Entities.Reporting" %>
Now you do not need to Add the full namespce for the class, You can simply access the class in your view. The code in your question would work fine.
If this class is defined in a Project other than your current UI project, you need to add a reference to that project under the References
section
Upvotes: 2