I am using MVC RC2.
I have Two tables 1)Product (PID, PName, CIDfk); 2)Category(CID, CName);
So i query like these
var Product = from p in dc.Product from C in dc.Category where p.CIDfk == c.CID select new { ProductName = p.PName, ProductCategory = c.CName }; return view();
where dc is database context of LINQ-to-SQL class (.dbml);
How do i display in view? where i pass Product? (in viewdata or in ‘return view()’)
Please help me out…
You can both use:
This way from the view you’d do:
or populate the model:
This way from the view you’d do:
After populating either ViewData or the Model you can call:
Another approach is calling the View overload that accepts the model as parameter, as tvanfosson said.