Copied to clipboard

Flag this post as spam?

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


  • Tarunjit 103 posts 146 karma points
    Jun 13, 2016 @ 08:45
    Tarunjit
    0

    Umbraco Drop Down Property returning integer value

    Hi,

    We have unpublished page with drop down property. On accessing propertyy value in the code we are getting numeric value of this property where as we have entered text value in dropdown items.

    Here is the code syntax we are using to fetch values from dropdown

    objContent= ApplicationContext.Current.Services.ContentService.GetById(1234);

    objContent.GetValue("propertyalias");

    Here "1234" is the pageID.

    Please help me on this.

  • Jan Skovgaard 11280 posts 23678 karma points MVP 11x admin c-trib
    Jun 13, 2016 @ 08:54
    Jan Skovgaard
    0

    Hi Tarunjit

    Perhaps you can benefit from using the same approach as Maff describes in his blogpost about getting the Text rather than the id of the dropdown value?

    http://maffrigby.com/umbraco-the-getprevalues-method-using-datatype-name/

    Hope this helps.

    /Jan

  • Jan Skovgaard 11280 posts 23678 karma points MVP 11x admin c-trib
    Jun 13, 2016 @ 08:57
    Jan Skovgaard
    0

    ..Or perhaps you can simply just use the .GetPrevalueAsString() method as describe d here https://our.umbraco.org/documentation/Reference/Querying/UmbracoHelper/ a bit down the page.

    /Jan

  • This forum is in read-only mode while we transition to the new forum.

    You can continue this topic on the new forum by tapping the "Continue discussion" link below.

Please Sign in or register to post replies