用asp.net中的剃刀视图中的总和

发布于 2025-02-06 03:25:52 字数 895 浏览 2 评论 0原文

我想做的是两个型号之间的总和(Razor asp.net)。 (它们是在数据库中创建的)我不想在控制器中进行操作,因为以后我希望它不修改我的值。 我需要以一种或另一种方式进行视图,要么通过删除foreach。非常感谢您,希望您的帮助。

<div class="cuartaParte">
        <table style="width: 100%">
          @foreach (var item in Model.PresupuestoDetalle){
          <tr> //here I want to do the sum
            <th scope="row" style="width: 70%; text-align: right">Descuento @[email protected]%</th>
            <td>[email protected]</td>
          </tr>
          }
        </table>
      </div>

What I want to do is a sum between two Models(razor ASP.NET). (they are created in the database) I don't want to do it in the controller, because later I want it not to modify my value.
I need to do it in the view one way or another, either by taking out the forEach. Thank you very much I hope your help.

<div class="cuartaParte">
        <table style="width: 100%">
          @foreach (var item in Model.PresupuestoDetalle){
          <tr> //here I want to do the sum
            <th scope="row" style="width: 70%; text-align: right">Descuento @[email protected]%</th>
            <td>[email protected]</td>
          </tr>
          }
        </table>
      </div>

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

寄风 2025-02-13 03:25:52

如果要在视图中显示两个模型之间的总和,请尝试使用@()外部model.cliente.cliente.descuentomodel.descuentoextraporcen%;

<div class="cuartaParte">
        <table style="width: 100%">
          @foreach (var item in Model.PresupuestoDetalle){
          <tr> //here I want to do the sum
            <th scope="row" style="width: 70%; text-align: right">Descuento @([email protected]%)</th>
            <td>[email protected]</td>
          </tr>
          }
        </table>
      </div>

If you want to show the sum between two Models in the view,try to use @() outside Model.Cliente.Descuento and Model.DescuentoExtraPorcen%;

<div class="cuartaParte">
        <table style="width: 100%">
          @foreach (var item in Model.PresupuestoDetalle){
          <tr> //here I want to do the sum
            <th scope="row" style="width: 70%; text-align: right">Descuento @([email protected]%)</th>
            <td>[email protected]</td>
          </tr>
          }
        </table>
      </div>
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文