如何在ASP.NET MVC中总结2列 [英] How to sum 2 column in ASP.NET MVC

查看:63
本文介绍了如何在ASP.NET MVC中总结2列的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我尝试在我的成绩视图中总结2列,但它只给我1个结果一列如何我可以总结为2列



< b>我尝试了什么:



这是我的观点:

I try To sum 2 column in my grade-view but it is only give me 1 result for one column how i can sum for the 2 column

What I have tried:

This is my view :

            <td>
                @Html.DisplayFor(modelItem => item.Debit)
            </td>

            <td>
                @{
    var RemaininAmount = item.contracts.AmountOfRent - item.Debit;
                }

                @RemaininAmount
            </td>


    </tbody>
}

<tr>

    <td>Total</td>
    <td>@Model.Sum(x => x.Debit)</td>
    <td>@Model.Sum(s => s.RemaininAmount)</td>

</tr>



这是mu输出:



ImgBBB - 上传图片 - 免费图片托管 [ ^ ]



谢谢


This is mu output:

ImgBBB - Upload Image — Free Image Hosting[^]

Thank you

推荐答案

正在计算RemaininAmount。如果模型中的名称值相同,则显然不同
RemaininAmount is being calculated. If you have a value of the same name in your model, it's obviously different


这篇关于如何在ASP.NET MVC中总结2列的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆