Developer forum

Forum » Templates » Show item's Editable list and Dropbox list in a template

Show item's Editable list and Dropbox list in a template

Andrey Kozachuk
Reply

Hello,

I have a paragraph-level item with Editable list and Dropdown list (with static options) fields and there are two questions:

1. How can I loop through Editable list in razor paragraph template?

2. How to get selected value of selected index of Dropdown list in razor paragraph template?

It should be pretty simple, but I didn't find documentation.


Replies

 
Merethe Vrå Andersen
Reply
This post has been marked as an answer

Hi,

1) Editable list values are listed directly in a comma seperated list with @GetString("Item.[FieldSystemName].Value") like this: Option1, Option2

2) To render the selected option, you can do this:

@foreach (var i in GetLoop("Item.[FieldSystemName].Options"))
{

 
 if (i.GetString("Item.[FieldSystemName].Option.IsSelected") == "True")
 {
  @i.GetString("Item.[FieldSystemName].Option.Label") 
 }

}

Kind regards,

Merethe

Votes for this answer: 1
 
Merethe Vrå Andersen
Reply

More Razor documentation in wiki:

https://github.com/dynamicweb/razor/wiki/From-Dynamicweb-HTML-to-Razor

and PDF.

 

 

 
Andrey Kozachuk
Reply

Thanks, it works:)

 

You must be logged in to post in the forum