在强类型视图中,我可以不呈现强类型部分吗?在强类型视图中显示强类型部分
我收到以下错误,当我尝试:
传递到字典的模型产品 类型的“System.Data.Linq.Table
1[UI.Models.vwProject]', but this dictionary requires a model item of type 'System.Collections.Generic.IEnumerable
1 UI.Models.ProjectStatus]” 。
我既填充使用ViewData.Model
public ActionResult Index()
{
ViewData.Model = project.vw_Projects;
return View();
}
public ActionResult ProjectStatus()
{
ViewData.Model = project.ProjectStatus;
return View();
}
这里的意见是我的看法:
<%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage<IEnumerable<UI.Models.vwProject>>" %>
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
<div>
<table>
<tr>
<th>
Project
</th>
<th>
Hours
</th>
</tr>
<tr>
<td>
<%= Html.Encode(item.ProjectCode) %>
</td>
<td>
<%= Html.Encode(item.ProjectHours) %>
</td>
</tr>
<div>
<% Html.RenderPartial("ProjectStatus"); %>
</div>
</asp:Content>
这里是我的部分:
<%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl<IEnumerable<UI.Models.ProjectStatus>>" %>
<table>
<tr>
<th>
Code
</th>
<th>
Status
</th>
</tr>
<% foreach (var item in Model) { %>
<tr>
<td>
<%= Html.Encode(item.ProjectCode) %>
</td>
<td>
<%= Html.Encode(item.ProjectStatus) %>
</td>
</tr>
<% } %>
</table>
我有点与强烈地显示强类型/动态偏分量相混淆类型或动态视图。有人可以帮我解决这个问题吗?
难道你需要在一个特定对象到'RenderPartial'通过?如果你不知道,它会从调用视图中获取模型。 – TLS
@TLS是的,我确实需要将特定的对象传递给RenderPartial – user793468