Copied to clipboard

Flag this post as spam?

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


  • Steve Morgan 1278 posts 4216 karma points c-trib
    Apr 17, 2015 @ 13:26
    Steve Morgan
    0

    Get DropDown value ID from the string - GetPreValuesCollectionByDataTypeId?

    Hi,

    I have a form with a drop down list built from an Umbraco drop down data type list. I want to use the ContentService .SetValue to set the value that the user selected in the content node so I think I need the internal prevalue ID of the value in the drop down.

    newPartnerNode.SetValue("businessSector", businessSectorId); 

    So how do I get the internal ID required to set the value?

    I've tried something like:

    IDataTypeService ds = ApplicationContext.Current.Services.DataTypeService; 
    IDataTypeDefinition SectorType = ds.GetAllDataTypeDefinitions().First(d => d.Name == "Business Sector Picker");
    int sectorId = ds.GetPreValuesCollectionByDataTypeId(SectorType.Id).PreValuesAsDictionary.Where(d => d.Value == submnission.BusinessSector).First().Id;
    
    This returns Expression cannot contain lambda 
    have I got to use PreValuesAsArray and loop through to find my item? 
  • Steve Morgan 1278 posts 4216 karma points c-trib
    Apr 17, 2015 @ 15:27
    Steve Morgan
    0

    I've inherited this project - I've just recreated the datatype and the newer version seems to be storing values as a Dictionary rather than an array? What could have caused this?

  • 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