Slow performance with MVC2 DisplayFor

Posted by PretzelSteelersFan on Stack Overflow See other posts from Stack Overflow or by PretzelSteelersFan
Published on 2010-03-22T14:40:10Z Indexed on 2010/03/22 14:41 UTC
Read the original article Hit count: 271

Filed under:

I'm iterating through a collection on my view model. The collection contains HealthLifeDentalRates which implement IBeginsEnds. I have a Display Template BeginsEnds that displays the date range. This results in very slow performance. If I simply the date range (see commented code), it's fine. I think how I'm defining the lambda is the problem but not sure how to change it.

<% foreach (var item in Model.Data.OrderBy(x=>x.HealthLifeDentalRateCode)) { %>

    <tr>
        <td>
            <%= Html.Encode(item.FiscalPeriodString()) %>
        </td>
        <td>
            <%= Html.Encode(item.HealthLifeDentalRateCode) %>
        </td>
        <td>
            <%= Html.Encode(item.Rate) %>
        </td>
        <td>
            <%= Html.Encode(item.IsDental.YesNo()) %>
        </td>
        <td>

<%= Html.DisplayFor(i => item, "BeginsEnds") %> - <%= Html.Encode(item.Ends.ToDateString()) %> --> <%= Html.Encode(String.Format("{0:g}", item.Loaded)) %> - <%= Html.Encode(item.LoadedBy) %>

<% } %>

© Stack Overflow or respective owner

Related posts about asp.net-mvc-2