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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T13:28:16+00:00 2026-05-30T13:28:16+00:00

I am new to MVC3 I am finding it difficult to create an dropdown.I

  • 0

I am new to MVC3
I am finding it difficult to create an dropdown.I have gone through all the other related questions but they all seem to be complex
I jus need to create a dropdown and insert the selected value in database

Here is what i have tried:

//Model class:
    public int Id { get; set; }
    public SelectList hobbiename { get; set; }
    public string filelocation { get; set; }
    public string hobbydetail { get; set; }
//Inside Controller
public ActionResult Create()
    {
        var values = new[]
        { 
            new { Value = "1", Text = "Dancing" },
            new { Value = "2", Text = "Painting" }, 
            new { Value = "3", Text = "Singing" },
        };
        var model = new Hobbies
        {
           hobbiename = new SelectList(values, "Value", "Text")
        }; 
        return View();
    } 
//Inside view
 <div class="editor-label">
        @Html.LabelFor(model => model.hobbiename)
    </div>
    <div class="editor-field">
        @Html.DropDownListFor(     x => x.hobbiename,     Model.hobbiename ) 
        @Html.ValidationMessageFor(model => model.hobbiename)
    </div>

I get an error:System.MissingMethodException: No parameterless constructor defined for this object

  • 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-30T13:28:18+00:00Added an answer on May 30, 2026 at 1:28 pm

    You are not passing any model to the view in your action. Also you should not use the same property as first and second argument of the DropDownListFor helper. The first argument that you pass as lambda expression corresponds to a scalar property on your view model that will hold the selected value and which will allow you to retrieve this value back when the form is submitted. The second argument is the collection.

    So you could adapt a little bit your code:

    Model:

    public class Hobbies
    {
        [Required]
        public string SelectedHobbyId { get; set; }
        public IEnumerable<SelectListItem> AvailableHobbies { get; set; }
    
        ... some other properties that are irrelevant to the question 
    }
    

    Controller:

    public class HomeController: Controller
    {
        public ActionResult Create()
        {
            // obviously those values might come from a database or something
            var values = new[]
            { 
                new { Value = "1", Text = "Dancing" },
                new { Value = "2", Text = "Painting" }, 
                new { Value = "3", Text = "Singing" },
            };
    
            var model = new Hobbies
            {
               AvailableHobbies = values.Select(x => new SelectListItem
               {
                   Value = x.Value,
                   Text = x.Text
               });
            }; 
            return View(model);
        }     
    
        [HttpPost]
        public ActionResult Create(Hobbies hobbies)
        {
            // hobbies.SelectedHobbyId will contain the id of the element
            // that was selected in the dropdown
            ...
        }
    }
    

    View:

    @model Hobbies
    @using (Html.BeginForm())
    {
        @Html.LabelFor(x => x.SelectedHobbyId)
        @Html.DropDownListFor(x => x.SelectedHobbyId, Model.AvailableHobbies) 
        @Html.ValidationMessageFor(x => x.SelectedHobbyId)
    
        <button type="submit">Create</button>
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

new to mvc3, i have a few questions, would appreciate if someone could answer/provide
I'm new to MVC3. I would like to create a select list / dropdown
I'm building a new Asp.Net MVC3 solution and would like to have all the
When I create a new MVC3 application, add a model, add a [Required] attribute
Whenever I create a new Empty MVC3 Web Application project in Visual Studio 2010
I have a new MVC3 application with a few legacy Web Form pages. I'm
I have just deployed a new MVC3 app to my hosting provider for the
I have a new MVC3 project with one Controller called PublicController.cs which contains 4
So I installed the new MVC3 tooling update and attempted to create a new
I have a new MVC3 project setup, and I added a folder inside my

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.