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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T03:00:42+00:00 2026-06-15T03:00:42+00:00

On my view I am using a list as my model and each list

  • 0

On my view I am using a list as my model and each list item is of type model, so it looks like this:

@model IEnumerable<UserManager.Models.vw_UserManager_Model>

and I am trying to loop through this list and add a specific property to a DropDownListFor:

@for (int i = 0; i < Model.Count(); i++)
{
    Html.DropDownListFor(model => model.ElementAt(i).module, new SelectList(Model, Model.ElementAt(i).module));
}

But when I do this it doesn’t render a dropdownmenu on my page.

Image of my list in locals

Can someone help?

  • 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-15T03:00:43+00:00Added an answer on June 15, 2026 at 3:00 am

    You can’t render a dropdown list for a model because there is no way of representing the model in its entirety in a dropdown. What is ASP.NET supposed to render?

    What you can do if you would like to select a model from a list is to run a LINQ Select query on the list, whereby you create an IEnumerable<SelectListItem> like this:

    var selectList = Model
        .Select(x => new SelectListItem
        {
            Name = x.module_name,
            Value = x.module
        });
    

    I have tried to take the values from the screenshot that you posted. Apologies if I made an error. You get the idea…

    What this code does is loop through the collection of your object type (Model.Select) and returns a collection of SelectListItem. If you are unfamiliar with LINQ you need to think of Select as a transformative function. It takes a collection, and for each element transforms it into something else and returns the result. Here, it takes each element of the Model collection and creates a SelectListItem. It then returns an IEnumerable<SelectListItem>.

    To render the list on the page you do the following:

    @Html.DropDownListFor(Model.MyValue, selectList)
    

    …where Model.MyValue is the variable which receives the selected value (assuming that the value, model is a string, which it appears to be).

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

Sidebar

Related Questions

I'm trying to create a page by using view 2. This page list all
I wanted to generate a list view using below code. But after running this
I am using a list view and an adapter for loading a list,each list
I have a model that looks something like this: public class SampleModel { public
I am creating a app in android. In that i am using list view.
I have created navigaton view using Sencha touch 2. Navigation view has list component
I am using a list view in Android 1.5 to show a list of
I have a view that renders a list elements using the following template :
Right now I am using a custom list view and I am inflating an
I'm using MVC3 with razor view. I'm giving the user a list of <li>

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.