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 created a data type called "Gearbox Type" which is using the drop down list editor, and has the following values;
var cs = Services.ContentService;var c = cs.CreateContent("Chris Test", 1267, "Gearbox");c.SetValue("historicId", "12345"); - this is a text stringc.SetValue("gearbox", "Manual"); - this is my dropdownc.SetValue("forwardGears", "10"); - this is a text stringcs.Publish(c);
When the content is created, the text string properties are saved OK, but my dropdown value is not selected. If I inspect the element I can see the Id's of each option and if I try the following, it doesn't work either;
c.SetValue("gearbox", 1) or c.SetValue("gearbox", "1");
What am I doing wrong here, has anyone done this before and can help out?
Well in case it's of any help I figured out a solution to my problem. You can see it here: http://stackoverflow.com/questions/18900069/updating-a-property-using-the-content-service-api-in-umbraco-6-x
Thanks I saw your post, I can't seem to get this working whether I use the ID or the Description. When you say ID, I assume you mean the value, which Umbraco creates, I can't specifiy the ID in the UI, I can just add the description?
If I try and access the property @Umbraco.Content(1316).GearBox, the value is returned, so it's storing in the database, but I need to have it selected for the content administrator!
What version of Umbraco are you using ? I am 7.1.4
I was using version 6.x although I wouldn't have thought it'd made much difference since AFAIK the process isn't any different in 7? (someone please correct me if I'm wrong)
Yeah , I think I have found the issue, I need to get the ID of the prevalue from the cmsdatatypeprevalues table, and use that ID when using the setvalue, I think there is a way to get that based on the text, so will look into it, thanks for your time in responding to my post
No worries - I was on the verge of tearing out handfuls of hair trying to figure this one out.. I just hope I can spare someone else the pain, haha.
is working on a reply...
Write your reply to:
Image will be uploaded when post is submitted