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 1349 posts 4458 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 1349 posts 4458 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?

Please Sign in or register to post replies

Write your reply to:

Draft