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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T02:21:43+00:00 2026-05-17T02:21:43+00:00

I know others have asked this question, but I’m totally confused by this: This

  • 0

I know others have asked this question, but I’m totally confused by this:

This displays the dropdown with no values selected:

<%= Html.DropDownList("items", new MultiSelectList(Model.AvailableItems,
    "id", "name", Model.items), new { multiple = "multiple" })%>

This displays the dropdown with the values that I’m passing in (Model.items) selected properly like what I’d expect:

<%= Html.DropDownList("somethingelse", new MultiSelectList(Model.AvailableItems,
    "id", "name", Model.items), new { multiple = "multiple" })%>

But the problem is that this item is now named “somethingelse” when i POST. I know I can hack around this but what’s going?

  • 1 1 Answer
  • 3 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-17T02:21:44+00:00Added an answer on May 17, 2026 at 2:21 am

    The problem you have is using Model.Items as a parameter. The code

    <%= Html.DropDownList("items", new MultiSelectList(Model.AvailableItems,
        "id", "name", Model.items), new { multiple = "multiple" })%>
    

    isn’t actually working as you would expect. It’s working because the name of the dropdown is “items”. That’s because there was a form param called “items” posted back to your action. That param gets stored in the action’s ViewState (don’t confuse with ViewData).
    The Html.DropdownList() sees that there is a ViewState param named the same as you have named your dropdown and uses that ViewState param to work out the selected values. It completely ignores the Model.items that you passed in.

    If anyone can explain the logic of not being able to override the default behavior then I’d love to hear it.

    So, that’s your first problem. To get around it all you have to do is to rename the dropdown to something else – exactly like you did in your second example. Now your second problem comes into play: the list of selected items must be a collection of simple objects (I think it actually needs to be an IEnumerable but I’m not 100% sure).

    The DropDownList() method will try and match those selected values to the Value in your AvailableItems collection. If it can’t do that it will try to match against the Text.

    So, try this to see if it works

    <%= Html.DropDownList("somethingelse", new MultiSelectList(Model.AvailableItems,
        "id", "name", Model.items.Select(c=> c.name)), new { multiple = "multiple" })%>
    

    Good luck

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

Sidebar

Related Questions

I know many have asked this question, but following the things suggested hasn't seemed
I know a lot of people have asked this question, but I still will
I know this question already have been asked. But I could not find any
I know this question has been asked several times for sure, but I have
There have been others that have asked this question but the common registry setting
I know many have asked this question before, but as far as I can
I know this question has been asked many and many times, but I have
I know this question has been asked before, but I've tried everything I could
I know this question has already been asked on this site before, but my
I hate to ask the same question others have asked in Stackoverflow, but I

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.