Adding a ItemTemplate into a repeater the new way

A colleague recently found a very easy way to add a ItemTemplate into your repeater
without having to create the ‘classic’ myTemplate : ITemplate class. So a nice example
of how less can be more:

1: rptPager.ItemTemplate = new CompiledTemplateBuilder( new BuildTemplateMethod(

BuildItemTemplate ) );

 2:

 3:

 4: void BuildItemTemplate(
Control container ) {

 5: LinkButton
lbPage = new LinkButton() { ID = "lbPage" };

 6: container.Controls.Add(
lbPage );

 7: }

Leave a Reply