Are you familiar with WebForms ITemplate?

time to read 1 min | 156 words

It looks like a lot of people are not familiar with this, and that is a shame.

Recently we have run into several instances where we wanted to do some things that are not supported out of the box by the repeater. Specifically, render an empty template and render markup after each row, except the first one, etc.

After some time thinking about how easy it would be to do this in MonoRail, I decided to implement it in the same way I would in MonoRail. WebForms has the concept of an ITemplate, a piece of markup/code that can be handed to a control for later processing. For the MonoRail guys, think about it like a section in a component.

By defining <EmptyTemplate> and <NotFirstRowTemplate> - I have been able to get it to work very easily. The only problematic part was where to render the template, but some reflectorring has given me the answer to that.