We have a small Asp.Net MVC project which displays a report of several tens or hundreds of rows of data. Each row is represented by an object on the view models.
Currently we are showing the rows like this:
<table>
<tr style="text-align:center">
<th>Name</th>
<th>Item count</th>
<th>Stat 1</th>
<th>Stat 2</th>
<th>Etc</th>
</tr>
<% var alternating = false;
foreach(RowItem rowItem in Model.RowItems)
{ %>
<%= Html.BeginRow(alternating) %>
<%= Html.ShowRow(rowItem) %>
<% alternating = !alternating; %>
<%= Html.EndRow() %>
<% } %>
</table>
Where BeginRow
, EndRow
and ShowRow
are helper extension methods that I wrote. ShowRow
is something like
public static string ShowRow(this HtmlHelper html, RowItem rowItem)
{
return "<tr><td>.... </tr>";
}
But I could also replace Html.ShowRow(rowItem)
with another partial view, i.e. Html.RenderPartial("RowControl", rowItem);
The question is, what are the advantages and drawbacks of these two approaches? All I can think of is that the partial view is more "designable" - easier to work with when the amrkup is complex, and by team members who specialise in "design" and "client development", i.e. html, css and javascript not c#. The HTML helper method is a just assembling a string containing the required html, which appeals to an old-school coder.
Which one, if any, has noticeable performance implications over hundreds of items? Are there maintenability impacts for either of them? All other things being equal, which would you choose to use?
We are on Asp.Net MVC 1.0 and Visual Studio 2008, but will probably upgrade some time in the next few months.