ASPX templates
Version 5.x > ASPX templates > Skipping Rows with a Repeater View modes: 
User avatar
Member
Member
Ian Muir - 8/19/2011 11:07:02 AM
   
Skipping Rows with a Repeater
I'm trying to figure out a way to skip rows with a repeater.

I have one cmsrepeater that displays 2 recent items using one transformation, but I need to create a second repeater that shows the 5 recent items after the first 2.

Is there a way to skip rows in a cmsrepeater?

User avatar
Kentico Developer
Kentico Developer
kentico_ivanat - 8/20/2011 9:57:37 AM
   
RE:Skipping Rows with a Repeater
Hi,

you could use following code to get an index of the row. The first item has an index 0. So you could write the transformation using this code. For example change css class for the first and second row. Or do not display them.
 <%# DataItemIndex==0?"First record":"Not firstrecord" %>

Best regards,
Ivana Tomanickova

User avatar
Member
Member
Ian Muir - 8/22/2011 7:12:51 AM
   
RE:Skipping Rows with a Repeater
I'll just write a custom control to do it. I'd prefer to avoid having a lot of extra non-presentational code in my transformations.

User avatar
Kentico Developer
Kentico Developer
kentico_helenag - 8/22/2011 7:19:41 AM
   
RE:Skipping Rows with a Repeater
Hi,

You can also write a special Where condition for the second repeater. For example:
NodeID NOT IN (SELECT TOP 2 NodeId FROM View_CMS_Tree_Joined WHERE <...> ORDER BY <...>)

Best regards,
Helena Grulichova

User avatar
Member
Member
cgilbu - 4/2/2013 8:19:23 AM
   
RE:Skipping Rows with a Repeater
Old post, but for u other guys:

Just modify this like u want and put it in the top of the transformation:
<% if (DataItemIndex == 0){return;} %>

This, for instance, will make the repeater skip the first row (row 0).