2sxc: Dropdown list Get Label instead of value in razor template

若如初见. 提交于 2020-01-06 17:09:11

问题


I have a dropdown in my contents like this https://snag.gy/OxgeoA.jpg where I have got 3 "labels:value" options.
In my razor template I would like to get the label instead of the value.
With this I only get the value (for example 0,1,2)

@Content.Name

How can I get Labels please? (for example Negativo,Positivo,Non Testato of my screens).
Thanks you

EDIT: I found a temp solution making a new entity, but I don't know if it is the right way because I thought that with a dropdown content field type I would be able to get label instead of the value..?


回答1:


Those labels only exist in the edit-dialog. They are not stored with the value, and can be different in every language. So your solution to create entities is usually the best way to do it, alternately you could just keep an array in your code and look it up. But the entity-list is probably your best solution.



来源:https://stackoverflow.com/questions/39977623/2sxc-dropdown-list-get-label-instead-of-value-in-razor-template

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!