Copied to clipboard

Flag this post as spam?

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


  • Tony Groome 261 posts 803 karma points
    May 11, 2015 @ 10:57
    Tony Groome
    0

    Getting member values from a dropdown

    Hi All

    Happy Monday! I am trying to get some member data from a dropdown list. The list is a list of branches whose alias is "branch" and have this code:

    var branch = member.GetValue("branch");

    This returns an int value and not the string value of branch which I am after. I tried:

    var branch = member.GetPropertyValue

    Thanks a lot.

    Tony

  • Dennis Aaen 4457 posts 17970 karma points admin hq c-trib
    May 11, 2015 @ 13:00
    Dennis Aaen
    101

    Hi Tony

    I think this will work for you.

    With the code above you should get the text and not the id of the selected value in the dropdown list.

    @foreach (var member in ApplicationContext.Current.Services.MemberService.GetAllMembers().OrderBy(member => member.Name)){
        var branch = Umbraco.GetPreValueAsString(member.GetValue<int>("branch"));
        <p>@branch</p
    }

    Hope this helps,

    /Dennis

  • Tony Groome 261 posts 803 karma points
    May 11, 2015 @ 13:04
    Tony Groome
    0

    Hi Dennis

    Genius! Thanks Dennis that worked a treat!

    First the office....next the world!!

    Tony

  • Dennis Aaen 4457 posts 17970 karma points admin hq c-trib
    May 11, 2015 @ 13:06
    Dennis Aaen
    1

    Hi Tony, 

    That´s nice to hear it worked, glad that I could help you.

    /Dennis

  • 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