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

  • Home
  • SEARCH
  • 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 8985391
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T21:19:10+00:00 2026-06-15T21:19:10+00:00

Might be simple but can´t find why I cannot access list attributes in my

  • 0

Might be simple but can´t find why

I cannot access list attributes in my view:

As you can see, I have a class that contains a list of RelacionamentoNomeadoModel class
Model:

    public class RelacionamentoNomeadoModel
    {
        public int idRelacionamento { get; set; }
        public string nomeTipoRight { get; set; }
        public string nomeTipoLeft { get; set; }
    }

    public class RelacionamentoListModel
    {
        public List<RelacionamentoNomeadoModel> lista { get; set; }
    }

Now I build the model and populate the RelacionamentoNomeadoModel class to later add it to the class containing the List
Controller

var relacionamentoObj = from r in context.sistema_relacionamento
                                        join d in context.sistema_DocType on r.idTipoLeft equals d.id
                                        select new tgpwebged.Models.SettingsModels.RelacionamentoNomeadoModel
                                        {
                                           idRelacionamento = r.id,
                                           nomeTipoLeft = d.tipoName,
                                           nomeTipoRight = d.tipoName
                                        };

                return PartialView(relacionamentoObj.ToList());

And the last I am trying to acces rela.lista.idRelacionamento or any other property.
I am able to access them from the controller bu not after I pass to the view
View

   @{
    List<tgpwebged.Models.SettingsModels.RelacionamentoListModel> relacionamentos = Model;

    foreach(var rela in relacionamentos) {
    rela.lista.
}

}

  • 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-15T21:19:12+00:00Added an answer on June 15, 2026 at 9:19 pm

    The problem is that you are passing to the View a collection of RelacionamentoNomeadoModel objects, while in the view you expect that the Model be a collection of tgpwebged.Models.SettingsModels.RelacionamentoListModel.
    Don’t know why you need RelacionamentoListModel class, but I think that if you use this code will be working fine:

    @{
        List<RelacionamentoNomeadoModel> relacionamentos = Model;
    
        foreach(var rela in relacionamentos) {
           // DO SOMETHING
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This might be a simple question but I've searched and searched and can't find
I have a simple requirement that might be tough to solve. I did find
might be a stupid simple solution but I can't seem to find what's wrong
It might look simple but I cannot find a solution for this. In my
This might be a simple question, but i can't seem to grasp it. I
This might be a simple one, but since I don't have much knowledge about
I know this might be a very simple and stupid fix, but I can't
I have a question that most of you might find a little odd. I
This might be simple question but have confused me for sometime. I'm developing an
I might actually be going insane, but I can't find a single example of

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.