Are you familiar with WebForms ITemplate?
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.
Comments
One of my fave uses of ITemplate it in UserControls...
Makes nice tiny components that are reusable and more intention-revealing
It's funny that you mention that, because I just stumbled across it yesterday when I was trying to create a test case for some code that was failing. I wanted to create a TemplateField programatically for a GridView and realized I would have to create an ITemplate object for the item template. I'll definitely be checking this out in more detail soon.
Comment preview