Copied to clipboard

Flag this post as spam?

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


  • Jesper 8 posts 51 karma points
    Oct 01, 2014 @ 11:34
    Jesper
    0

    Update selected value of Backoffice dropdownlist from contentservice

    Hello!

    How do I update the selected value of a dropdownlist page property using ContentService (or other)?

    I have a property on a page called "state". This is of type Dropdown list. I've added a few prevalues in Backoffice. Now I'm trying to set the selected option of the dropdown list to one of the prevalues using ContentService.

    The problem is, I don't know what it expects as a value. I tried with a string and an int and it does save the value (I can see it in the umbraco.config) as

    <state><![CDATA[myValue]]></state>

    . But it never updates the backoffice property selected value.

    Here's my code (here I'm setting the value from an Enum):

    var service = new ContentService();
    var content = service.GetById(myContentId);

    content.SetValue("state",DocumentState.Modified.ToString());
    content.UpdateDate = DateTime.Now;

    service.SaveAndPublishWithStatus(content);

    public enum DocumentState
        {
            Created = 0,
            Modified = 1,
            Completed = 2,
            Removed = 3
        }

    Any ideas on this would be very much appreciated :)

  • Jeroen Breuer 4861 posts 12138 karma points MVP 3x admin c-trib
    Oct 01, 2014 @ 12:08
    Jeroen Breuer
    0

    Hello,

    So you're trying to link a dropdown to an enum? In that case it might be easier to have a look at nuPickers. I've also got an example on how to use an enum with a dropdown in the Hybrid Framework.

    Jeroen

  • Jesper 8 posts 51 karma points
    Oct 01, 2014 @ 12:14
    Jesper
    0

    Hello, and thanks for your answer!

    Anything is fine really. I just need to know how to set the selected value of a Backoffice dropdown list property from code. :)

    Btw, the link http://projects/developer-tools/hybrid-framework-for-umbraco-v7 is not working..

    Best,
    Jesper

  • Jeroen Breuer 4861 posts 12138 karma points MVP 3x admin c-trib
    Oct 01, 2014 @ 12:56
  • 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