Copied to clipboard

Flag this post as spam?

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


  • paul 2 posts 72 karma points
    Apr 13, 2017 @ 11:55
    paul
    0

    Saving Profileproperties with multiple values

    Hi I've created a profile property of th type Umbraco.DropDownMultiple

    No I want that the member can edit this property on his own. I've used the default Edit Profile Macro. Now the profile is displayed as a single line of text.

    Therefore I needed to create a new EditorTemplate.

    I want to create a multi-select list.

    The problem I face is that I can only select 1 value in it; If I select more than 1 value; the value doesn't get correctly updated.

    Can you help me? This is my code:

    @Html.LabelFor(m => profileModel.MemberProperties[i].Value, profileModel.MemberProperties[i].Name)
                   List<SelectListItem> cities = new List<SelectListItem>()
                            {
                                new SelectListItem() { Value = "1016", Text= "Washington DC" },
                                new SelectListItem() { Value = "1017", Text= "Los Angeles" },
    
                            };
                   List<string> TagIds = profileModel.MemberProperties[i].Value.Split(',').ToList();
                   MultiSelectList multiselectlist = new MultiSelectList(cities, "Value", "Text",selectedValues: TagIds);
    
                   @Html.ListBoxFor(m => profileModel.MemberProperties[i].Value, multiselectlist)
                   @Html.HiddenFor(m => profileModel.MemberProperties[i].Alias)
    

    When I select only "Washington DC" - it stores the value on my members profile

    When I select only "Los Angeles" - it stores the value on my members profile

    But when I select both, it doesn't work the way I want.

    I've tried several ways to accieve this, but none has helped me so far... I want the values stored in comma seperated (just like it is stored when editting the member in the backoffice).

    How would you approach this?

  • paul 2 posts 72 karma points
    Apr 14, 2017 @ 14:43
    paul
    0

    To Expand this question:

    In the PartialViewMacroPage "Edit Profile" is this short description:

     @* 
                    By default this will render a textbox but if you want to change the editor template for this property you can 
                    easily change it. For example, if you wanted to render a custom editor for this field called "MyEditor" you would
                    create a file at ~/Views/Shared/EditorTemplates/MyEditor.cshtml", then you will change the next line of code to 
                    render your specific editor template like:
                    @Html.EditorFor(m => profileModel.MemberProperties[i].Value, "MyEditor")
     *@
    

    Where are good examples for this to edit member properties, other than just a single string in a textbox. I'm looking for good examples for editors for "Date", "Date & time", Multi Selectbox, etc.

    I'm searching all over the internet but haven't found a decent solution yet.. Can anyone point me in the right direction?

Please Sign in or register to post replies

Write your reply to:

Draft