String builder vs. repeater (whis is best?

Hey guys,
I have written such a code to loop through the records and build a string.
Is this s good idea or should I use repeater or something?

    key = "PageComponents_dataFeedVisitCount";
    StringBuilder strTopPages = new StringBuilder();

    DataFeed dataFeedVisitCount;

    if (cache[key] == null)
    {
        dataFeedVisitCount = service.Query(query1);
        if (cache[key] != null) cache.Remove(key);
        cache.Insert(key, dataFeedVisitCount, null, DateTime.Now.AddDays(1), TimeSpan.Zero);
    }
    else dataFeedVisitCount = (DataFeed)cache[key];

    strTopPages.Append("<table>");
      foreach (DataEntry entry in dataFeedVisitCount.Entries)
    {
        i = i + 1;
        string st = entry.Title.Text;
        int ss = Convert.ToInt32(entry.Metrics[0].Value);
        string[] SplitedPagePathTitle = st.Split(new char[] { '|' });
        
          strTopPages.Append ("<tr>");
          strTopPages.Append("<tr><td><a href=\\"" + ReplacePageString(SplitedPagePathTitle[1]) + "\\" target=\\"_blank\\"><img border=\\"0\\" src=\\"../images/icons/url_icon.gif\\"></a> <a href=\\"" + ReplacePageString(SplitedPagePathTitle[1]) + "\\">" + ReplacePageString(SplitedPagePathTitle[0]) + "</a>" + "</td>");
        strTopPages.Append ("<td>" + ss.ToString("#,#") +"</td>");
        strTopPages.Append("</tr>");          
    }
      strTopPages.Append("</table>");
      ltrTopPages.Text = strTopPages.ToString();

^^^Or just make user controls to encapsulate these UI things in a more natural way then hardcoding HTML . . .

One word of warning though. You can’t nest repeaters that deep. In the example you show, the Repeater would make this simpler to read and understand. However, if you needed a repeater to create a series of tables and you need TableRepeater to repeat the tables, and then you need a RowRepeater to do each row of the table, and depending on your table, perhaps a CellRepeater to repeat cells along the row. I know as soon as I hit three I couldn’t get things to work, though I read about people who’ve done it. However, I know of no one who’s gone any deeper than three. So if you “wanted” to put a list in each cell and use a ListItemRepeater to construct the items in each list, I believe you’d be out of luck. Much less going any deeper than that. For a complex :drink:application, working programmatically let’s you nest your for loops as deep as you want. More importantly, by the time you get three repeaters nested inside each other, a lot of those “readability” advantages are gone. At that point, doing things programmatically is superior because you can encapsulate each level of abstraction so you’re always looking at just one level plus the function call which handles all the levels below.

^^^What they said. Other advantage of repeater is the change cycle is much better. No need to recompile and perhaps redeploy the tweak the UI, just edit the ASPX template, save and refresh.

repeater is much easier and manageable.

Go Repeater, it will make your code much more readable. Or go one better and use the MVC framework.

(your example reminds me of one of my first ASP.Net projects… I still cringe when I think about it)