On the Details view I want to display a grid from other table. How to implement it better? I'm trying to do it in a such a way (error: Cannot implicitly convert type 'void' to 'object'):
<%= Html.RenderPartial("~/Views/Appartament/Index.ascx", new { id = Model.blockhouse_id })%>
Here is the code from details view:
<%@ 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>
And the code of the Index.ascx controller:
public ActionResult Index(int blockhouse_id)
{
var _appartament = apt.GetBlockAppartaments(blockhouse_id).ToList();
return View("Index", _appartament);
}
RenderPartial
doesn't have a return value.
Instead of
<%= %>
Use
<% %>
As for Razor, instead of
@
Use
@{ }
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.