0

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|

2
  • @Mastermind, that's a bit uncalled for. Anyway, @Vikas, could you clarify your question a little more? Commented May 23, 2009 at 8:55
  • @BobbyShaftoe: Basically, the question is, I need to program something, I don't know how to program [something], tell me how to program [it]. Commented May 23, 2009 at 9:09

1 Answer 1

1

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.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.