DataTable中的列内容在MVC3列表中显示在一行中 [英] Column Contents In DataTable To Display In One Row In MVC3 List
问题描述
你好!
我有一张桌子。看起来像这样:
Employeename |详情|出勤日期|
========================================
本杰| 124 | 2013.09-20 |
本杰| 345 | 2013.09-20 |
Benjie | 356 | 2013.09-21 |
Benjie | 466 | 2013.09-21 |
本杰| 517 | 2013.09-22 |
本杰| 912 | 2013.09-22 |
汉娜| 102 | 2013.09-22 |
汉娜| 97 | 2013.09-21 |
Rose | 251 | 2013.09-21 |
Rose | 297 | 2013.09-22 |
Rose | 302 | 2013.09-20 |
Rose | 364 | 2013.09-20 |
我希望我的清单显示如下:
Employeename | 2013.09-20 | 2013.09-21 | 2013.09-22 |
================= ==========================================
本杰| 124 | 345 | 356 | 466
汉娜| 102 | 97 | | | | |
玫瑰| 251 | 297 | 302 | 364
这里的任何人都可以展示如何做到这一点在C#?
hello there!
i have a Table. looks something like this:
Employeename|Details |AttendanceDates|
========================================
Benjie |124 |2013.09-20|
Benjie |345 |2013.09-20|
Benjie |356 |2013.09-21|
Benjie |466 |2013.09-21|
Benjie |517 |2013.09-22|
Benjie |912 |2013.09-22|
Hannah |102 |2013.09-22|
Hannah |97 |2013.09-21|
Rose |251 |2013.09-21|
Rose |297 |2013.09-22|
Rose |302 |2013.09-20|
Rose |364 |2013.09-20|
and I want my list to show like this:
Employeename|2013.09-20|2013.09-21|2013.09-22|
===========================================================
Benjie |124 |345 |356 |466
Hannah |102 |97 | | | | |
Rose |251 |297 |302 |364
can anyone here show how to do this in C#?
推荐答案
如下所示循环播放
Just loop through like below
@model IEnumerable<person>
@{
ViewBag.Title = "IndexTest";
}
<h2>IndexTest</h2>
<p>
@Html.ActionLink("Create New", "Create")
</p>
<table>
@foreach (var item in Model) {
<tr style="border: none">
<td style="border: none">
|
@Html.DisplayFor(modelItem => item.FirstName)
</td>
<td style="border: none">
|@Html.DisplayFor(modelItem => item.LastName)|
</td>
</tr>
}
</table></person>
希望这有帮助
Hope this helps
这篇关于DataTable中的列内容在MVC3列表中显示在一行中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!