repeaterdataitem

how to get next item in repeater c#, if list is given as datasource?


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?


Solution

  • 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);