ASPX templates
Version 4.x > ASPX templates > Wrapping content/putting clearer div in ASCX Transformation View modes: 
User avatar
Member
Member
tony - 1/20/2011 6:41:22 PM
   
Wrapping content/putting clearer div in ASCX Transformation
Hi everybody!

I have just figured out a handy solution and wanted to share it with everyone here.
For example if you need to put clearer div after every 3 items in repeater, you can put the following expression in transformation:
<%# (DataItemIndex%3)-2==0?"<div class=\"clear\"></div>":"" %>

This comes very handy when you are handling thumbs in the image gallery.

Also this method can be used to dynamically wrap the items when displaying data with repeater (for example wrapping 6 items within div element ):

transformation:
<%# (DataItemIndex%6)==0?"<div id=\"wrapper\">":"" %>
// code that needs to be wrapped in div
<%# (DataItemIndex%6)-5==0 || DataRowView.DataView.Count==(DataItemIndex+1)?"</div>":""

Hope you’ll find it useful!