If you’re familiar with the ASP.Net repeater control then you will know that when laying out the repeater contents you can have individual style for alternating rows so far example every other row could have a different background. But what if you wanted more sophisticated options, say for example you wanted to do a news style repeater with the first item having a photo and an in depth story, then next five having a picture and summary and the remaining items having just a headline.
Well I found a great tip on how you can do this with a single repeater. The way to do it is to set up panels inside your repeaters item template, as the example below:
<asp:Repeater id="myRepeater" runat="server">
<ItemTemplate>
<asp:PlaceHolder ID="PlaceHolder1" runat="server" Visible='<%# (Container.ItemIndex = 0) %>' >
<div>
My First Item Controls
</div>
</asp:PlaceHolder>
<asp:PlaceHolder ID="PlaceHolder2" runat="server" Visible='<%# (Container.ItemIndex >=1) and (Container.ItemIndex <5) %>' >
<div class="underlined">
My Next Five Item Controls
</div>
</asp:PlaceHolder>
<asp:PlaceHolder ID="PlaceHolder3" runat="server" Visible='<%# (Container.ItemIndex >= 5) %>' >
<div
The Reminder Of My Items Controls
</div>
</asp:PlaceHolder>
</ItemTemplate>
</asp:Repeater>
So you set up a panel for each of the individual styles that you require and then the Visible property of the panel is derived from where we are currently in the list of items. Nice and easy, requires no complex code behind tricks and works like a charm.
Hope this will be of help to someone out there, it certainly was to me.
My blog is mainly about programming in .Net 2, website promotion and affiliate marketing although I do have the odd ramble on about anything that comes to mind.

