Copied to clipboard

Flag this post as spam?

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


  • Matthew 93 posts 153 karma points
    May 31, 2012 @ 07:39
    Matthew
    0

    get prevalue text from dropdown

    Hi, stuck again. Just trying to get the nvarchar text from a prevalue in a dropdown to show in a template, instead of the number. Anyone spare a snippet?

    Thanks,

    Matthew

     

  • Carsten Fallesen 35 posts 154 karma points
    May 31, 2012 @ 08:17
    Carsten Fallesen
    0

    Hi Matthew,

    You should be able to get the prevalue text with:

    @umbraco.library.GetPreValueAsString(Model.YourProperty)

    - Carsten

  • Matthew 93 posts 153 karma points
    May 31, 2012 @ 17:35
    Matthew
    0

    Thank you Carsten.  I had run across that and did finally get a version of that to do it, modifying a snippet from:

    http://our.umbraco.org/wiki/reference/umbracolibrary/getprevalueasstring

    Here's what my current version looks like:

    @{
      var myValues = Model.FIELD;
      foreach(var id in myValues.Split(',')) {
        var myStringValue = umbraco.library.GetPreValueAsString(Convert.ToInt32(id));
        <li>@myStringValue </li>
      }
    }

     As a dufus, I learn best (although slowly) by doing first, learning after.  I can see that this is working but I'm pretty sure there's no reason to have a foreach in there, since I only need to show the one value.  I'm working on simplifying that now.

    Thanks again.

  • Matthew 93 posts 153 karma points
    May 31, 2012 @ 18:00
    Matthew
    0

    There, that's got it, for any other dufus following along:

    @{ var myStringValue = umbraco.library.GetPreValueAsString(Convert.ToInt32(Model.FIELD));
    <p>@myStringValue</p>
    }
Please Sign in or register to post replies

Write your reply to:

Draft