Search code examples
asp.net-mvc-4razorumbraco

Render LayoutGrid of child article in umbraco?


I have a article witch has multiple related article. this related articles have a layout grid. now I want to render this grids below of my main article. I get this related article by this code:

 @{
     var children = Model.Content.GetPropertyValue("relatedArticles").ToString().Split(',');
  }
  @foreach (var child in children) {
      Umbraco.Content(child).GetGridHtml("gridLayout");
  }

but GetGridHtml() function donot work. in umbraco documentation GetGridHtml only is accesible from @CurrentPage. how can I render these grid layout?


Solution

  • I finally found my solution by using this method:

    @{
         var children = Model.Content.GetPropertyValue("relatedArticles").ToString().Split(',');
     }
     @foreach (var child in children) {
          var data = Umbraco.TypedContent(child);
          @Html.GetGridHtml(data, "gridLayout");
     }