Good morning, basically my question is that: I have an mvc razor application that loads a data context with several tables and views. Once loaded all the models (in my viewmodel) armo grillas using for loops in the following way:
@for (int i = 0; i < Model.Grilla.Count; i++)
{
<tr id="@Model.Grilla[i].campo1">
<td>
@Html.DisplayFor(x => Model.Grilla[i].campo1)
</td>
<td>
@Html.DisplayFor(x => Model.Grilla[i].campo2)
</td>
</tr>
}
... 4 more grids
The problem I have when executing, being a lot of records (400 per grid) and many grids (approx 6) and all generated at the same time, I exploited the memory of Visual Studio 2015, showing me the following error:
An exception of type 'System.OutOfMemoryException' occurred
The particular thing about this error is that it only occurs when I want to debug from Visual Studio, if I publish the website and execute it, it runs without major problems (although it takes about 20-30 seconds to boot).
My question is this:
-Is there a way to prevent the for loops from being called at the same time? (like using a flag or calling each other at the end of each one, or giving them an execution number)
-Is there any way to put an "index" to the loop for faster data handling?
-Is there a faster way to use for loop?
-Any way to execute the for loop from JQuery / Javascript to prevent the page from loading them at the same time? (without having to rewrite all the code of the grid in javascript)
Thanks !!