I want to filter out / remove items from a list of type Sitecore.Data.Items. This is how i fill the list.
List<Item> actueelItems = Sitecore.Context.Database.SelectItems("/sitecore/content/destil_nl/Home/").ToList();
I have a method that checks wheter an item is valid. This will return true or false. I want to put up a new list, that i will call the filteredList with only the valid items in it.
What's the best way to achieve this?
This by the way is my validate method:
public static bool ValidateItem(Item item)
{
return ValidateItem(item, true);
}
public static bool ValidateItem(Item item, bool checkVisualization)
{
bool result = true;
if (item.Versions.Count <= 0 ||
!item.Publishing.IsValid(DateTime.Today, false) ||
(checkVisualization && item.Visualization.GetLayout(Sitecore.Context.Device) == null))
{
result = false;
}
return result;
}
Currently i am using the check in the itemDataBound but then the item will still be shown, only with the wrong values. I figured i have to filter the list, and give the filtered list as datasource. I just don't know how i can easily filter this list using the ValidateItem.