Note that there are some explanatory texts on larger screens.

plurals
  1. POWhy Repeaters in ASP.NET?
    text
    copied!<p>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.</p> <p>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?</p> <p><strong>In rails I would do...</strong></p> <p><em>controller</em></p> <pre><code>@types= Type.find(:all) </code></pre> <p><em>view</em></p> <pre><code> &lt;%@types.each do |t| %&gt; &lt;%= t.name %&gt; &lt;%= link_to "view", t%&gt; &lt;%end%&gt; </code></pre> <p><strong>In ASP.NET I'd do:</strong></p> <p><em>controller class attributes</em></p> <pre><code>protected List&lt;Type&gt; _types = null; </code></pre> <p><em>controller class PageLoad</em></p> <pre><code>_types = MethodThatGetTypeFromDB(); </code></pre> <p><em>view</em></p> <pre><code>&lt;% foreach (var tin _types){%&gt; &lt;%= t.name %&gt; &lt;%}%&gt; </code></pre> <p>There are no repeaters, but the code is clean, DRY and respects the MVC AP. I don't create methods everywhere to handle <code>ItemDataBound</code> 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?</p> <p>I think I'm just not getting the idea here. </p> <p>I'm <strong>not</strong> 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.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload