Developer forum

Forum » Templates » Get Items inside an Itemlist?.

Get Items inside an Itemlist?.

Mikkel Toustrup Olsen
Reply

Hello - I have setup x amount of items, each representing a name (country name) and an itemlist containing another item type(employees with name, title, phone etc.).

I was wondering if its possible to retrieve the respective employees from each item (with an item list of employees by LINQ`?) .. 

I manage to output the different countries to a dropdown(select) - and my goal is, that "onchange" on this dropdown it should call a @helper method which outputs the Danish employees (if Denmark is chosen), German employees (If Germany is chosen) .

I am doing something like the following, but with no luck: 

 

@foreach(LoopItem i in GetLoop("ItemPublisher:Items.List").Where(e=>e.ItemListName == "Denmark, Germany etc.." .. or something of the sort?..

Cheers,

Must say, I am able to retrieve all the employees fields -> but I cant get the Where statement to work, which is quite essential to my above-mentioned functionality :-)

MIkkelTO


Replies

 
Mikkel Ricky
Reply
This post has been marked as an answer

You have to use GetString on the item in the Where clause, e.g. something along the lines of

var country = ...;
foreach (var i in GetLoop("ItemPublisher:Items.List").Where(e => e.GetString("ItemPublisher:Item.XXXX").Contains(country))) { … }

Best regards,
Mikkel

Votes for this answer: 1
 
Mikkel Toustrup Olsen
Reply

Sure did the trick, thanks Mikkel :-)

 

/MikkelTO

 

You must be logged in to post in the forum