Why Repeaters in ASP.NET?

asp.net, c#, repeater, ruby-on-rails, webforms

Solution

Repeaters fit nicely into the code-behind approach. I spent many years where I couldn't stand the sight of any code in the markup. All code belonged in the code-behind separated from the markup. This was largely a reaction to the horrid messes I dealt with in classic ASP.

Now with ASP.Net MVC, I find I'm going back to exactly what you describe above. But, I'm finding it hard to overcome the instinct to keep markup and code separate.

Edit: Here's an article from 2003 about the debate regarding code-behind.

Problem

I'm a Ruby on Rails / PHP guy, and my company got me to work with ASP.NET. It's not too bad, I'm glad to learn a new language but since I started working with this technology everyone is bothering me about Repeaters. The thing is that I totally fail of seeing the point: what make using a repeater better than just displaying things in a loop? Am I going to programmers' hell for this? In rails I would do... controller ``` @types= Type.find(:all) ``` view ``` <%@types.each do |t| %> <%= t.name %> <%= link_to "view", t%> <%end%> ``` In ASP.NET I'd do: controller class attributes ``` protected List<Type> _types = null; ``` controller class PageLoad ``` _types = MethodThatGetTypeFromDB(); ``` view ``` <% foreach (var tin _types){%> <%= t.name %> <%}%> ``` There are no repeaters, but the code is clean, DRY and respects the MVC AP. I don't create methods everywhere to handle `ItemDataBound` or whatever. So what's the idea here? Am I the only one that find that repeaters are a pain to set up and are not worth it compared to the advantages they bring? I think I'm just not getting the idea here. I'm not trying to start a battle rails vs the world, it's just that this is what I know the best so this is the paradigm I'm trying to find when I'm developing. I think it's more convenient and I'm used to it, but if someone goes "Repeaters are good because A, B and C, doing what you're doing is terrible because D, E and F", then I'll admit it and change my approach.

Original source