【问题标题】:what is the best way to create dynamic html table in asp.net mvc?在 asp.net mvc 中创建动态 html 表的最佳方法是什么?
【发布时间】:2017-08-10 14:08:31
【问题描述】:

我的问题是“在效率的概念上,为 Asp.net Mvc 项目在 html 中创建动态表的最佳方法是什么”?

另一方面,我可以在 html 中为带有 foreach 循环的 Asp.net Mvc 项目创建动态表吗?

谢谢

【问题讨论】:

    标签: html asp.net-mvc dynamic foreach html-table


    【解决方案1】:

    在 html 中创建动态表格的最佳方法是什么

    “最佳方式”是一个非常主观的术语。但是一种简单的方法正是您所建议的...

    我可以用 foreach 循环在 html 中为 Asp.net Mvc 项目创建动态表吗?

    当然。假设您的视图模型上有某种集合,您只需遍历该集合并从中发出值。就这么简单:

    <table>
    @foreach (var item in model.SomeCollection)
    {
        <tr><td>@item.SomeValue</td></tr>
    }
    </table>
    

    所有代码正在做的就是迭代项目集合并为该集合中的每个元素发出标记和值。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-06-14
      • 2021-06-03
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-01-12
      相关资源
      最近更新 更多