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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T06:25:35+00:00 2026-06-12T06:25:35+00:00

How would I generate a select list, where the text field, is made up

  • 0

How would I generate a select list, where the text field, is made up of two or more text columns, eg: Where I have a Description and Rate field in my database, I want to combine these to show:

Large--£200
Medium--£150
Small--£100

Controller code is:

 var stands = db.Stands.Where(s => s.ExhibitorID == null).ToList();
 ViewBag.StandID = new SelectList(stands,"StandID", "Description" + "-- £" + "Rate");

…and my view is (currently):

    <div class="editor-field"> 
        @Html.DropDownList("StandID", "--Select--") 
    </div> 

…but the “Description” + “– £” + “Rate”); won’t run:

DataBinding:
‘System.Data.Entity.DynamicProxies.Stand_63F8C9F623B3C0E57D3008A57081AFCD9C39E1A6B79B0380B60840F1EFAE9DB4’
does not contain a property with the name ‘Description–£Rate’.

Thanks for any help,

Mark

  • 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-12T06:25:36+00:00Added an answer on June 12, 2026 at 6:25 am

    You could create a new anonymous class using a simple LINQ projection, and then use the SelectList(IEnumerable, string, string) constructor overload to specify the value and text fields to be used for the <option> elements i.e.:

    var stands = 
      db.Stands
        .Where(s => s.ExhibitorID == null)
        .Select(s => new 
         { 
           StandID = s.StandID,
           Description = string.Format("{0}-- £{1}", s.Description, s.Rate) 
         })
        .ToList();
    
    ViewBag.StandID = new SelectList(stands, "StandID", "Description")
    

    Edit

    In C#6 and later, string interpolation makes for better reading than string.Format

       ...
       Description = $"{s.Description}-- £{s.Rate}"
    

    If you project to a strong ViewModel class name (instead of to an anonymous class), you will undoubtedly want to replace the magic strings with the safety of the nameof operator:

    ViewBag.StandID = new SelectList(stands, nameof(Stand.StandID), nameof(Stand.Description));
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to use simplified select one tag, which would generate select items list
I have two tables, one containing a list of different options users can select
I need to create a simple application that would generate reports based on database
I would like to generate POJO, XML for a given database. Database: ( contents
I have a select box that gets generated dynamically. I want to allow users
I have a select list with products on clicking an add button you it
I have a gender select field (--Select--, Male, Female) and I'm populating that in
Background I have two select form fields chained together: duration and frequency. When the
I have two tables, custassets and tags . To generate some test data I'd
I have a list of pages that I want to list in the sidebar

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.