Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • stephen 8 posts 53 karma points
    Sep 24, 2014 @ 14:02
    stephen
    0

    Partial View and IEnumerable Model

    Really struggling with this.

    I have a partial view which uses an IEnumerable model (returning data as a list)

    ---umbraco template---

    @inherits Umbraco.Web.Mvc.UmbracoTemplatePage

    @{

        Layout = "Master.cshtml";

    }

    @Html.Partial("AgeGate", new IEnumerable<Example.Models.Products>) //want to call the PartialView

    ----Partial View---

    @model IEnumerable<Example.Models.Products>

    @{

        ViewBag.Title = "Index";

    }

    <h2>Index</h2>

    @foreach (var item in Model)

    {<text>TEST</text>}

    --Controller---

    public class AgeGateController : SurfaceController

     

        {

    public PartialViewResult AgeGate()

            {

                var alldat = db.tblAgeGates;  //gets db results

                return PartialView(alldat.ToList()); //return List

            }

    }

    Q. What do I need to do correctly call the IEnumerable model ?

     

Please Sign in or register to post replies

Write your reply to:

Draft