Quantcast
Channel: ASP.NET Core
Viewing all articles
Browse latest Browse all 9386

How to Display Total

$
0
0

I have a ViewComponent:

<h4>Kitset Parts</h4><table class="table"><tr><th>
                Product Code</th><th>
                Quantity</th><th>
                Product Description</th><th>
                Cost Price ex G.S.T.</th><th>
                Line Total ex G.S.T.</th></tr>


        @foreach (var p in Model)
        {
            <tr><td>

                    @p.Product.ProductCode
                </td><td>

                    @p.Quantity
                </td><td>
                    @p.Product.ProductDescription.Substring(0, Math.Min(p.Product.ProductDescription.Length, 38))</td><td>

                    @p.Product.CostPrice
                </td><td>
                    @(p.Product.CostPrice * p.Quantity)</td><td><a asp-controller="ProductKitset"
                       asp-action="Details"
                       asp-route-id="@p.ProductKitsetID">More Details</a></td></tr>


        }

        </table>

I know I can get a sum total using @Model.Sum(w.Product.CostPrice*w.Quantity) and this suits me as at this point all I am wanting is a display of the cost price, I don't want to store it, and I don't want to use it other than as information as to what the cost of this specific Kitset is costing at this point.

What I want to display is:

Quantity  Product  Price  Line Total

1         Widget        3.00     3.00

2         THingies      4.00     8.00

Total                                  11.00

I can do the first part easily.  I just don't understand how to show the total line.  I can get the total to repeat on each line, I can get the total to repeat as a separate line within the table, I just don't understand how to add the total in the view I can see it can be done.  Just not how to do it?


Viewing all articles
Browse latest Browse all 9386

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>