Developer forum

Forum » Templates » Check if loop is empty

Check if loop is empty

Hans Ravnsfjall
Hans Ravnsfjall
Reply

Hi

There is probably a really simple answer to this, but right now I am stuck - and canĀ“t find a solution.

I want to check if a loop contains any instances or not - or in other words, I want to check if a loop is not empty.

The loop is "Item.Historikkur"

How do i use DW Template Razor to check if it is emtpy or not?

/Hans


Replies

 
Imar Spaanjaars Dynamicweb Employee
Imar Spaanjaars
Reply
This post has been marked as an answer

You can check it using Any():

var items = GetLoop("Item.Historikkur");
if (items.Any())
{

}

Votes for this answer: 1
 
Hans Ravnsfjall
Hans Ravnsfjall
Reply

Fantastic Imar :)

Thank you very mutch

 

You must be logged in to post in the forum