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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T04:18:22+00:00 2026-06-06T04:18:22+00:00

In my MVC3 application i have a dropdown list. In there i have to

  • 0

In my MVC3 application i have a dropdown list. In there i have to show all the results, but some results must be disabled, so that they are not selectable. How can i do that?

This is what i have right now. It simply doesn’t show the players that have Disabled set to true.

@Html.DropDownListFor(m => m.Position1, Model.SelectedTeam.TeamPlayers
                     .Where(c => c.Player.Disabled == false)
                     .OrderBy(t => t.Player.Lastname)
                     .ToSelectList(m => m.FullName, m => m.PlayerId))

So is there another way to also show the Disabled players, but that the output would be like this, instead of just hiding them completely:

<select>
  <option>Player 1</option>
  <option disabled="disabled">Player 2</option>
  <option>Player 3</option>
  <option>Player 4</option>
  <option disabled="disabled">Player 5</option>
  <option>Player 6</option>
</select>

Is that possible with a DropDownListFor?

  • 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-06T04:18:24+00:00Added an answer on June 6, 2026 at 4:18 am

    OK, here’s the ‘hard way’ of doing it. 🙂 Maybe someone else will have a better idea.

    First, you’d need to differ between valid and disabled entries on the select list – and only way to do it is either by value or text of the option. Let’s say the invalid values will have the value == "disabled", otherwise it’s a valid ID:

    //Somewhere in the controller
    ...
    var list = yourViewModel.SelectedTeam.TeamPlayers.OrderBy(p => p.LastName).Select(new SelectListItem
        {
            Text = item.LastName,
            Value = item.Disabled ? "disabled" : item.PlayerId.ToString()
        }).ToList();
    
    //pass it however you want, in the model or by ViewBag
    ViewBag.MyDropDownList = new SelectList(list, "Value", "Text");
    

    And then in the view

    @Html.DropDownListFor(model => model.Position1, ViewBag.MyDropDownList as SelectList);
    
    $(document).ready(function()
    {
        $(#"Position1 option[value=\"disabled\"]").prop("disabled",true);
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following dropdown list in an MVC3 application and the selected item
In my application (MVC3) i have bind culture info list to dropdown and as
I'm developing an ASP MVC3 application and I have some views that are related
I have a ASP.NET MVC3 application that gets a List of Coordinates from a
I have a MVC3 application with some XML files on the App_Data folder. To
I have a ASP.NET MVC3 application that handles time-consuming processes (copying a large file
In my MVC3 application, I have a queries class specific to each controller that
i have created an mvc3 web application that uses forms based authentication. one part
I have an MVC3 application that has a custom HandleErrorAttribute so that I can
MVC3 vb.net Application using built in session management. I have an mvc3 application that

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.