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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T21:19:15+00:00 2026-05-20T21:19:15+00:00

In my list and details view I need to show the value (name) instead

  • 0

In my list and details view I need to show the value (name) instead of the id (int). The catch is I only have one collection. So only the the EnteredBy name is showing. The Model.Entries.Staff only contains one item not all possible matches.

// model
    public class Entry
    {
        [Display(Name = "Assigned To")]
        [Column(Name = "AssignedToId")]
        [Required(ErrorMessage = "You must select an individual.")]
        public int AssignedToId { get; set; }

        [Display(Name = "Entered By")]
        [Column(Name = "EnteredById")]
        [Required(ErrorMessage = "You must select an individual.")]
        public int EnteredById { get; set; }

        public virtual Staff Staff { get; set; }
    }

// view
    @foreach (var item in Model.Entries)
    {
            <td>
                @(item.AssignedToId == null ? "None" : item.Staff.Name))
            </td>
            <td>
                @(item.EnteredById == null ? "None" : item.Staff.Name)
            </td>
    }
  • 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-05-20T21:19:15+00:00Added an answer on May 20, 2026 at 9:19 pm

    Have you considered using a ViewModel pattern to solve this?

    The way I usually do this is I create a ViewModel class that contains both the Model for the page and a property that holds the the list values for my lookup. Here is an example:

    In my View I have (Razor):

    @Html.DropDownListFor(model => model.ModelObject.leagueId, 
        new SelectList(Model.LeagueList, "leagueId", "leagueName"), 
             "--Select League--", "name='ModelObject.leagueId'")
    

    ModelObject is my actual editable Model…

    Then in my ViewModel I have:

    public LeagueSeasonRoList LeagueList { get; set; }
    public Team ModelObject { get; set; }
    

    In my model, I have a leagueId property which ties it all together.

    Then in the controller, instead of using the Editable object directly as my model, I use the ViewModel.

    You’ll need to make a few adjustments so all your references are correct but I have used this pattern many times with success.

    hth,

    \ ^ / i l l

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

Sidebar

Related Questions

I have a question. I have a list view (A) and a details view
Im trying to do bind a dropdown list to a details view but keep
In my ASP.Net MVC 3 view, I have a popup where I need to
I need to implement the abcd list indexing in the below table view right
I've got an app with two screens, we can call them List and Details.
How do I get a list of the running processes (with details of PID,
I want to access my Aweber account details and my email list in a
I installed Services Module and REST Server to get list of products and details.
I am trying to get data for my collection_select list. Details There are 4
I have a website that has products list page and product detail page .

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.