c# - Accessing items in multiple models in a single view in MVC4 -


I have an issue on how to access variables from various scenes in mvc. The way I have installed it , I have a scene on which I would like to display values ​​from several models. I know that to repeat through the items, I have to use the predecessor, but I do not know how to reach other people.

In this way I say this model in this view: @modelInMerebal & lt; MyApp.Models.Problems & gt;

This is my model where I am trying to use values:

  public class problems {public Ent ID (get; set) ;} Public String title {get; set;} Public IEnumerable & lt; MyApp.Models.Category & gt; Categories {receive; set;} Public IEnumerable & lt; MyApp.Models.Type & gt; Type {Receive; These are my other models:  
  Public Partial Category Category {Public Ent ID}; Set;} Public That string title {get; set;}} public partial class type {public id id (get; set;} public indefinite order {receive; set;} public string description {get; set;}}   

Here's an example of what I'm trying to do:

This loads the title in my problem model which is being loaded: @ html.DisplayNameFor (model = & gt; model.Title)

But I want to see it in the same scene Be able to call the line title, anyone can talk about any thoughts or me in the right direction. It will be highly appreciated !!!

This is what you want to get nested foreach Loop can use:

  @forach (problem problems in model) {foreach (Problems in category category. Categories) {@ Html.DisplayNameFor (category = & gt; @ Category. )} ...}   

You may have to add a statement by using the at the top of your code to see the names included in your model: i.e. :

  @ MyApp.Models    

Comments

Popular posts from this blog

Java - Error: no suitable method found for add(int, java.lang.String) -

java - JPA TypedQuery: Parameter value element did not match expected type -

c++ - static template member variable has internal linkage but is not defined -