在详细信息视图中,我想显示来自其他表的网格。如何更好地实施?我正在尝试以这种方式进行操作(错误:无法将类型“void”隐式转换为“object”):
<%= Html.RenderPartial("~/Views/Appartament/Index.ascx", new { id = Model.blockhouse_id })%>
以下是详细信息视图中的代码:
<%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage<testMVC.Models.Blockhouse>" %>
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
<h2>Details</h2>
<p>
blockhouse_id:
<%= Html.Encode(Model.blockhouse_id) %>
</p>
<p>
name:
<%= Html.Encode(Model.name) %>
</p>
<p>
Appartaments:
<%= Html.RenderPartial("~/Views/Appartament/Index.ascx", new { id = Model.blockhouse_id })%>
</p>
</asp:Content>
以及 Index.ascx 控制器的代码:
public ActionResult Index(int blockhouse_id)
{
var _appartament = apt.GetBlockAppartaments(blockhouse_id).ToList();
return View("Index", _appartament);
}