How to get next item in repeater by index or any other way?
e.g. in Sitecore if I'm getting the current item in repeater as
Item currentItem = (Item)e.Item.DataItem;
How can I get item which is next in the list which is given as the datasource?
Thanks Thomas ,
I got one similar approach . Declared list global and in repeater databound used :
int index = myList.IndexOf(currentItem); Item nextItem = myList.ElementAt(index + 1);
You should make the Item List available to the method where you need it. Then you could do something like this:
Item currentItem = (Item)e.Item.DataItem; Item nextItem = MyList .SkipWhile(item => item.ID != currentItem.ID) .Skip(1) .FirstOrDefault();
Thanks Thomas ,
I got one similar approach . Declared list global and in repeater databound used :
Item currentItem = (Item)e.Item.DataItem;
int index = myList.IndexOf(currentItem);
Item nextItem = myList.ElementAt(index + 1);