1
I am making a report, I was able to make him bring me the data of specific dates, but I need now that he brings me the sum of everything that was selected, I made an attempt but does not bring the sum of everything, only some things were added up.
My View:
Report Sale by Order/Period From: @Viewbag.dataRead to @Viewbag.dataFinal
<tr>
<th>N° Carro </th>
<th>Quant. </th>
<th>Km </th>
<th>Valor Unitário </th>
<th>Sub Total </th>
<th>Data Abastecimento </th>
</tr>
@{foreach (var item in Model)
{
foreach(var iten in Model)
{
<tr>
<td> @Html.DisplayFor(modelItem => iten.NumCarro.NCarro) </td>
<td> @Html.DisplayFor(modelItem => iten.Litro) </td>
<td> @Html.DisplayFor(modelItem => iten.Km) </td>
<td> @Html.DisplayFor(modelItem => iten.VlrUnit) </td>
<td> @Html.DisplayFor(modelItem => iten.TotalGasto) </td>
<td> @Html.DisplayFor(modelItem => iten.DtAbastecido) </td>
</tr>
}
}
}
He is doing the sum directly in the view, I do not know if it has to apply by the controller, in my view what returns me is this sum.
I think the problem is in the above loop...
– Rovann Linhalis
I put more things before the view
– Guilherme Padovam
puts.... has 2 nested foreach there...
– Rovann Linhalis
just take out the first foreach...the sum is correct
– Rovann Linhalis
could put the answer only I to give right there
– Guilherme Padovam