Copied to clipboard

Flag this post as spam?

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


  • Matt Brownell 4 posts 24 karma points
    Oct 24, 2014 @ 18:22
    Matt Brownell
    0

    Iterating through grid properties returns individual chars

    sorry if this is terribly simple/noob question...though it's enough to stump me.  I've successfully installed ver. 1.1.1 and using it to store a bunch of text fields.  i'm simply trying to iterate through the fields in my razor code.  when i attempt to access the individual property, the foreach returns the first character of the whole property vs. the first item.  snippets below.  any help is appreciated!

    we're using Umbraco 7.1.6.  my razor is in a macro script (so the only using statement is: @inherits umbraco.MacroEngines.DynamicNodeContext).

    code snippet:

     foreach (var priceRow in Model.dailyAdmission)

                            {

                                var test = priceRow.memberType;

    }

    when i look at value of priceRow (in VS2013) i see:  91'['

    when i look at value of Model.dailyAdmission (in VS2013) i get:

    [
    {
    "memberType": "nonmember",
    "adult": "20",
    "junior": "14",
    "senior": "16"
    },
    {
    "memberType": "member",
    "adult": "7",
    "junior": "6",
    "senior": "6"
    }
    ]

    this feels like i'm missing an include/using statement or using the wrong parser somewhere.

     

    thanks,

    Matt

  • Matt Brownell 4 posts 24 karma points
    Oct 24, 2014 @ 20:03
    Matt Brownell
    0

    to add to my confusion.  i tested putting the above snippet directly into my page (vs. my macro.cshtml which is included into my <scripts> section at bottom of page).  since it is on my page, my header contains the @inherits Umbraco.Web.Mvc.UmbracoTemplatePage and i can use CurrentPage reference.

     

    it workes just fine.  meaning, referencing priceRow.memberType returns the 'member' or 'nonmember' appropriately.

    so, some difference between accessing the data on my page vs. doing it in a macro/code-block.  is there a simple way around this (i like to keep my scripting code gathered together and easy to manipulate vs. buried in the page HTML).

    thanks,

    matt

Please Sign in or register to post replies

Write your reply to:

Draft