Click here to Skip to main content
15,892,005 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
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#?
Posted

1 solution

Just loop through like below
C#
@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
 
Share this answer
 
Comments
Er Daljeet Singh 25-Sep-13 5:23am    
NO i don't think it works because <tr> in inside the loop or secondly the model should have records in format the user want to display.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900