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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T11:14:55+00:00 2026-06-16T11:14:55+00:00

I have an ASP.NET MVC 4 C# application and I want to display data

  • 0

I have an ASP.NET MVC 4 C# application and I want to display data from 3 different models in one view.

The schemas are related via foreign keys like this:

Model A | Model B | Model C
ID      | ID      | ID
          A_ID    | B_ID

In View for model A, I want to be able to to display data that is linked in B and C.

Right now, in the View for Model A (Details) I can do:

@model Application.Models.A

@foreach (var b Model.B)
    {
        @Html.DisplayFor(modelB => B.Title)
        <br />
    }

I want to be able to then do:

@foreach (var b Model.B)
    {
        @Html.DisplayFor(modelB => B.Title)

        @foreach (var c Model.B.C)
        {
            @Html.DisplayFor(modelC => C.Title)
            <br />
        }

        <br />
    }

You can do this in ruby on rails, how can I do this in MVC 4?

  • 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-16T11:14:59+00:00Added an answer on June 16, 2026 at 11:14 am

    I figured it out.

    I had the models, controllers and relationships setup correctly. I just needed to modify my view to the following:

    @foreach (var b in Model.Bs)
        {
            @Html.DisplayFor(B => b.Title)
            <br />
            foreach (var c in b.Cs)
            {
                @Html.DisplayFor(C => c.Title)
                <br />
            }
        }
    

    Thanks.

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

Sidebar

Related Questions

I have an asp.net mvc application where I want to hide/display part of form
I have an ASP.NET MVC application that is using a single view to display
I have asp.net mvc application, that uses razor view engine. I want to send
I have created blank Asp.Net-MVC 3 web application and want to write my own
I have a Asp.net MVC web application, containing mostly text. I want to put
I currently have an ASP.NET MVC application that exists. I want to add a
I have an asp.net mvc application with three layers: - data layer with entities
I have an ASP.NET MVC application and I want to make links written in
I have asp.net mvc application. i want to configure the object in jquery and
I have an asp.net mvc application where i want the user to be able

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.