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 8226799
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T15:54:04+00:00 2026-06-07T15:54:04+00:00

I have two model classes, each is a table in a database. One model

  • 0

I have two model classes, each is a table in a database. One model is called ‘Clothes’ and the other ‘Shoes’.

I want to display the contents of each table in the same razor view, but MVC is only letting me send one model to the view.

@model IEnumerable<Test.Models.Clothes>

Is there a way to send more than one model to a razor view?

If not, what is the normal way to display contents of another model in a view that has already got another model passed to it. Thanks for advice.

  • 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. Editorial Team
    Editorial Team
    2026-06-07T15:54:07+00:00Added an answer on June 7, 2026 at 3:54 pm

    Either make a view model class which has both the class as its object. It would be then type safe.

    public class ViewModelForDisplay
    {
           public Clothes Clothes {get; set;}
           public Shoes Shoes {get; set;}
    }
    
    //on Controller
    Clothes objClothes = GetClothes();
    Shoes objShoes = GetShoes();
    
    ViewModelForDisplay objViewModel = new ViewModelForDisplay() {Clothes = objClothes, Shoes= objShoes }
    

    The other easy way to do it by using ViewBag.It uses the dynamic feature that was added in to C# 4. It allows an object to dynamically have properties added to it. Its also Type Safe

    ViewBag.Shoes= objShoes ;
    ViewBag.Clothes= objClothes ;
    

    You could also use ViewData to pass objects to html. BUt this would not be type safe. It requires casting

    ViewData["Clothes "] = objClothes ;
    ViewData["Shoes "] = objShoes ;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Given two model classes, Foo and Bar , I want Foo to have 3
I have two classes (MVC view model) which inherits from one abstract base class.
I have two classes that each need an instance of each other to function.
I have defined two models where each one references the other, like so: class
I have two model classes, say parent and child. Parents are created first, and
I have two questions. 1: At the moment I have two model classes that
I have a hibernate model with two classes, let's say A and B. B
I have a simple Fluent NHibernate model with two related classes: public class Applicant
I have two models: The model NetworkObject try to describe hosts. I want to
I have two classes defined such that they both contain references to the other

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.