Getting content from list items in a list
Hello,
I am trying to programmatically get the content from all the list items present in a list that I created in Sitefinity. I am trying to access the title and content in each of the list items and display it on a page. I am trying to databind the content that I get from the list of RadListView. Could you please suggest me any posts/documentation where I can find more information about getting content from a list and databind it to a RadListView?
I have looked the API and I am having difficulty in getting the content for each of the items in the list. I am using the following code below:
ListsManager manager = ListsManager.GetManager();
ListItem listitems = manager.GetListItems()
.Where(i => i.Parent.Title == "FAQ")
.Single();
Part of the problem is that you used a .Single which would return a single ListItem...methods like .Where return IEnumerable so you can loop though the results
Try this (or some variation)
foreach
(var item
in
App.WorkWith().ListItems().Where(x => x.Parent.Title == "FAQ").Publihed().Get())
string
title = item.Title;
string
content = item.Content;
Steve,
Thank you for your post. Yes, that did the trick for me to get all the list items. Now, I am working on binding it to a output template.
Thank you.