MVC 4 Linq Group in Two Column View?

I currently have one column showing in the View. I would like to have two or more columns side-by-side and grouped by Date as shown below.

09/2013                         10/2013
Food         $300.00         Food       $320.00
Housing   $600.00         Housing  $600.00
Utility       $200.00         Utility      $200.00

[View]
       <table>
                <thead>
                    <tr><td>09/2013</td></tr>
                    <tr>
                        <td><b>Category</b></td>
                        <td></td>
                        <td><b>Limit</b></td>
                    </tr>
                </thead>
                <tbody>
                    @foreach (var group in Model)
                    {
                        <tr>
                            <td>@group.category.Name</td>
                            <td></td>
                            <td>@group.budget.Limit.ToString("c")</td>
                        </tr>
                    }
                </tbody>
            </table>

[Action]
        public ActionResult Index()
        {            
            var budgets = from b in context.Budgets
                          join c in context.Categories on b.CategoryID equals c.CategoryID
                          select new BudgetViewModel { category = c, budget = b };

            return View(budgets.ToList());
        }

Open in new window

WorknHardrAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Bob LearnedCommented:
What is your question?

How to create a group in LINQ?

How to modify the view to show the output?
0
WorknHardrAuthor Commented:
I don't know how to group the rows into columns by date (month/year).

It will be both Linq and Html coding...
0
Bob LearnedCommented:
Simple Group By expression:

var results = from e in Employees
              group p.Task by p.EmployeeId into g
              select new { EmployeeId = g.Key, Tasks = g.ToList() };

Open in new window

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
WorknHardrAuthor Commented:
I took more than a Simple Group by Expression. Thanks for making me rethink the Group clause. My final Linq is below.

var budgets = (from b in context.Budgets
                          join c in context.Categories on b.CategoryID equals c.CategoryID
                          let j = new BudgetViewModel { category = c, budget = b }
                          group j by j.budget.Date into g
                          select new Group<DateTime, BudgetViewModel>
                                { Key = g.Key, Values = g.OrderBy(s => s.category.Name) });
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
ASP.NET

From novice to tech pro — start learning today.