Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 148733
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T09:00:41+00:00 2026-05-11T09:00:41+00:00

I am using MVC RC2. I have Two tables 1)Product (PID, PName, CIDfk); 2)Category(CID,

  • 0

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…

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. 2026-05-11T09:00:41+00:00Added an answer on May 11, 2026 at 9:00 am

    You can both use:

    - ViewData['MyName'] = product.SingleOrDefault();  

    This way from the view you’d do:

     <% Product p = (Product)ViewData(p) %> 

    or populate the model:

    ViewData.Model = product.SingleOrDefault(); 

    This way from the view you’d do:

    <%Product p = ViewData.Model%> //in case of a Strongly typed view <%Product p = (Product)ViewData.Model%> //otherwise 

    After populating either ViewData or the Model you can call:

    return View(); 

    Another approach is calling the View overload that accepts the model as parameter, as tvanfosson said.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm using ASP.NET MVC RC2. I have a set of classes that were auto-generated
I'm working on an ASP.NET MVC app (using MVC3 RC2). Say I have 2
I have developed a small application using MVC RC2. The application works fine in
I am currently using ASP.NET MVC 2.0 RC2, having recently moved from version 1.0.
Im using MVC-Viewmodel, EF Model first on my project. I have a foreach loop
I am using MVC 3 architecture in my project. I have a master page
I am using MVC C# along with Jquery. I have a partial view in
I am using Telerik asp.net mvc extensions. I have an issue that happens only
Using MVC 2 I have been trying to make this record store project. Creating
im using mvc framework and i have learned some techniques that help me with

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.