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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T04:35:10+00:00 2026-05-16T04:35:10+00:00

I have the following database schema: Here’s how I populate a DropDownList in my

  • 0

I have the following database schema:
alt text

Here’s how I populate a DropDownList in my AreaController.cs:

public ActionResult Edit(int id)
{
    Area area = areaRepository.GetArea(id);
    JefeRepository jefe = new JefeRepository();
    ViewData["Jefes"] = new SelectList(jefe.FindAllJefes().ToList(), "ID", "Nombre", area.Jefe.Nombre);
    return View(area);
}

Then in my View I display it like so:

<%: Html.DropDownList("IDJefe", (SelectList)ViewData["Jefes"]) %>  

The DropDownList loads correctly but only shows the Name of the Jefe. I want to display both name and last name. How can I achieve this?

I’ve tried doing something like this but it only display the first name.

ViewData["Jefes"] = new SelectList(jefe.FindAllJefes().ToList(), "ID", "Nombre", area.Jefe.Nombre + area.Jefe.Apellido);

This is how it shows:
alt text

  • 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-16T04:35:11+00:00Added an answer on May 16, 2026 at 4:35 am

    In your class you can make an property which will combine it for you and also can be bind to your list, f.e. if I have Person class:

    public class Person
    {
       public int Id { get; set; }
       public string FirstName { get; set; }
       public string LastName { get; set; }
       public string FullName { get { return string.Format("{0} {1}", FirstName, LastName); } }
    }
    

    Then you can easily bind it like:

    ViewData["Persons"] = new SelectList(persons, "Id", "FullName ", ...);
    

    As far as it have just the getter it will not involved into your business logic processes – it will only helps 😉

    PS. Sorry for another example, but I really do not understand spanish 😉

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

Sidebar

Related Questions

I have no control over database schema and have the following (simplified) table structure:
I have a database schema that is similar to the following: | User |
I have a database where I store objects. I have the following (simplified) schema
I have following database schema for tabel tblpers Field Type Null Key Default Extra
I have the following database relational schema that purports to model an EMP supertype
I have a MySQL innodb database at 1.9GB, showed by following command. SELECT table_schema
I have the following database table created thus: CREATE TABLE AUCTIONS ( ARTICLE_NO VARCHAR(20),
Let's say I have the following database table: record_id | record_date | record_value -----------+-------------+--------------
In PHP, I have following Singleton Database Class: class Database { private static $instance;
I have the following criteria Database should be protected with a username and password.

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.