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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T00:43:40+00:00 2026-06-17T00:43:40+00:00

Problem Description: I am using ASP.NET MVC and I have the following method in

  • 0

Problem Description:
I am using ASP.NET MVC and I have the following method in my Controller Class. This method uses SelectList method to select a list of items from the database. These items will then be passed to the view to be displayed in a drop down list.

public ActionResult Edit(int id)
{
    Album album = db.Albums.Find(id);

    ViewBag.ArtistId = new SelectList(db.Artists, "ArtistId", "Name", album.ArtistId);
    return View(album);
}

My Understanding of the selectMethod:

I know that the first param takes a list of items.
The third param is the property to be displayed.In this case, we will be displaying the name property of the Artists.
Based on my research, I found out that the 4th param is the default value that will be displayed on the dropdown list.

My Question:

1) I would like someone to help me understand about the second param.

2)Since we are displaying names of the artists, how can we display a default artist name in the fourth param using Artist ID?

I hope you guys understood my questions. I would be happy to clarify them to you if you need me to do so.

  • 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-17T00:43:41+00:00Added an answer on June 17, 2026 at 12:43 am
    1. The second parameter is the name of the “value” property or field on each element in the first parameter. Since two artists could conceivably have the same, it’s generally better to use an ID column (as in the example) so that you know specifically which item was selected.
    2. In the example, you are providing the artist of the currently-viewed album as the default to appear. Assuming that db.Artists includes an artist whose ArtistId property matches the given value, the rendered HTML will produce a select list where that artist is selected.

    Did that answer your questions?

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

Sidebar

Related Questions

I am using asp.net mvc 2.0(default binding model) and I have this problem. I
I'm using ASP.NET MVC 3 (Razor) and have created a Controller named Controllers -
I am using Entity Framework with ASP.NET 4.0. This is a simple problem where
I have a problem using Regex, in ASP.NET website. I wanna get the counts
I have recently started using ASP.Net MVC 3 RC 2 and have attempted to
I have simple ASP.NET MVC action like this : public ActionResult Edit(EditPostViewModel data) {
I am following http://www.mikesdotnetting.com/Article/125/ASP.NET-MVC-Uploading-and-Downloading-Files . Using VS2010, ASP.NET 4.0, MVC3 in C# with ADO.NET
I'm having a small problem with ASP.NET MVC and Entity Framework 4. I have
I have a rather large ASP.NET MVC web application which uses KnockoutJS extensively throughout.
I'm using ASP.Net MVC Design pattern and when adding a controller to my application

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.