My problem isn't the saving the node is created and all values are filled except for the the datatype dropdownlist values. But if the above is the correct way of doing it, I must be doing something else wrong:)
but neither option seems to work. I get the data stored in the umbraco.config file, however, when viewing the created page in Umbraco, the dropdown lists don't show the selected value.
I assume this is about the dropdownlist that comes OOTB with Umbraco. The control that is shown in the editor extends System.Web.UI.WebControls.DropDownList and the value it saves is the SelectedValue of the DropDownList that is rendered in the editor.
I'm not sure what the model is in your example above, but it should be something like this (the SelectedValue corresponds to the value you set in your PreValues, which is Id, Value - and I believe the Id is the SelectedItem):
Sounds like the approach I'm taking, although I'm stumped as to get the Id & Value of the item I need.
I need to set property to a particular string (in this case it's "noindex, nofollow" for our search criteria), so it's just a case of matching this to an item in the dropdownlist defined on the page. I've got this so far, but I still can't get the page to show the selected value when I pass the string to it.
How to set the value of the dropdownlist datatype
I'm creating a document in Razor and i would like to know how to set the value of a dropdownlist
dropdownlist has values:
prevalue value
paid 145
not paid 146
this code doesn't work and google didn't supply me with an answer :(
Any help?
Kind regards,
Garret
Hi Garret
Seems like you don't save and publish the document.
Have a look at the documentation here http://our.umbraco.org/documentation/Reference/Management/Documents/ - Go to the section "Creating a Document and setting properties" and have a look at that example.
Be aware that there is a typo in the last line: umbraco.librarh.UpdateDocumentCache(d.Id); it should read umbraco.library.UpdateDocumentCache(d.Id);
Hope this helps.
/Jan
Hi Jan,
My problem isn't the saving the node is created and all values are filled except for the the datatype dropdownlist values.
But if the above is the correct way of doing it, I must be doing something else wrong:)
Tnx for helping out
Bumping this topic - I'm trying to do something similar!
How do you use the API to create a page and populate/select an item on drop-downs?
I've tried looking up the property itself and passing through the key/value of the selected item e.g.
and setting the value itself as a string or from the model e.g.
but neither option seems to work. I get the data stored in the umbraco.config file, however, when viewing the created page in Umbraco, the dropdown lists don't show the selected value.
Any help is appreciated!
I assume this is about the dropdownlist that comes OOTB with Umbraco. The control that is shown in the editor extends System.Web.UI.WebControls.DropDownList and the value it saves is the SelectedValue of the DropDownList that is rendered in the editor.
I'm not sure what the model is in your example above, but it should be something like this (the SelectedValue corresponds to the value you set in your PreValues, which is Id, Value - and I believe the Id is the SelectedItem):
Hope this helps,
- Morten
Sounds like the approach I'm taking, although I'm stumped as to get the Id & Value of the item I need.
I need to set property to a particular string (in this case it's "noindex, nofollow" for our search criteria), so it's just a case of matching this to an item in the dropdownlist defined on the page. I've got this so far, but I still can't get the page to show the selected value when I pass the string to it.
is working on a reply...