Press Ctrl / CMD + C to copy this to your clipboard.
This post will be reported to the moderators as potential spam to be looked at
I have a dropdown datatype which i add to / delete from within the front end on save.
So for example when a company is created on the front end it saves the name and id into a datatype within umbraco, this is then loaded on a create job page so that the user can select the company from a drop down.
I have the code adding it into the prevalues list, however it needs to have the modelbuilder regenerated before it will show the new option in the drop down.
How can i get it to refresh the datatype on save, so that it updates the dropdown instantly rather than requiring a manual modelbuilder regeneration.
Prevalue insert code
Dictionary<string, PreValue> updatedPreValues = new Dictionary<string, PreValue>();
var preValues = Services.DataTypeService.GetPreValuesCollectionByDataTypeId(1384).PreValuesAsDictionary;
foreach (var preValue in preValues.Where(pv => !pv.Value.Value.Contains(companyDisplayName)))
Pre Value controller read:
private SelectList GetSelectListForCompanies()
var preValueDataType = Umbraco.DataTypeService.GetPreValuesCollectionByDataTypeId(1384);
var preValues = preValueDataType.PreValuesAsDictionary.Values.Where(pdv => pdv.Value != "0");
var companiesList = preValues.Select(preValue => new SelectListItem
Value = preValue.Id.ToString(),
Text = preValue.Value
companiesList.Insert(0, new SelectListItem()
Text = "Company",
Value = "0",
Selected = true,
Disabled = true
return new SelectList(companiesList);
I realise that this is an old question, but in case it helps anyone who lands here after a search (as I did), I found that saving the datatype itself fixed this issue for me.
var dataType = Services.DataTypeService.GetDataTypeDefinitionById(guid);
is working on a reply...
Write your reply to:
Image will be uploaded when post is submitted