Reputation: 12567
Is it generally best to avoid calling to render partial in a loop situation...
<% foreach (var buildingRate in locationBuildingRate.BuildingRates)
{
Html.RenderPartial("LocationBuildingRate", buildingRate);
}
%>
And instead allow the rendering to loop inside the partial? Does this second way avoid a lot of overhead?
Html.RenderPartial("LocationBuildingRate", locationBuildingRate.BuildingRates);
Upvotes: 1
Views: 1651
Reputation: 42246
The best way to handle this is to leverage EditorTemplates and DisplayTemplates, which basically renders a partial but is less expensive.
Upvotes: 0
Reputation: 2763
Yes. Calling a render partial inside a loop would request the rendering engine for each run. Better to do the second approach where you loop inside the partial..
Upvotes: 1