tags:

views:

324

answers:

1

I have one table structure Like

1)Id 2)Date 3)score

Filtered by date, I can show number of rows (Display field: Score).

and on one page I what to show records of 3 dates (3 consequent dates, Stored in tables).

Format should look like....

Date1 Date2 Date3

score score score

score score score

score score score

... ... ...

should I create my own model using existing Model Classes?

I don't know what will be in your mind, but can user control help me in this situation?

Please Help me...

Update on public Demand

using

<% foreach (var item in Model) { %>
<% } %>

I each record can be displayed easily in index view.

What about above structure??

If you don't get then...

records :

1 21/2/2009 29

2 21/2/2009 50

3 21/2/2009 54

2 21/2/2009 77

2 23/2/2009 55

2 23/2/2009 44

2 23/2/2009 66

2 24/2/2009 53

Display

21/2/2009| 23/2/2009| 24/2/2009

29| 55| 53

50| 44|

54| 66|

77|

+1  A: 

I've posted this from my mind - so there can be typos/errors.

First you need a custom Model:

public class ScoreColumnViewModel {
    public DateTime Date;
    public List<int> Score;
}

In your Controller create a list of your ScoreColumnViewModel (assuming Linq-To-Sql):

var dates = /* dates to select */

var scoreColumns = dates.Select(date =>
    new ScoreColumnViewModel {
        Date = date;
        Score = DB.Scores.Where(x => x.Date == date).
                    Select(x => x.Score).ToList();
    }
).ToList();

In your View:

<% foreach(var column in Model) { %>
    <table>
        <tr><th><%= column.Date %></th></tr>
        <% foreach(var score in column.Scores) { %>
            <tr><td>score</td></tr>
        <% } %>
    </table>
<% } %>

In your css:

table {
    float: left;
}

My solution is not ideal but it could be a starting point for you.

eu-ge-ne