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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T08:17:41+00:00 2026-05-23T08:17:41+00:00

I’ve got a page that contains two lists, one empty, one populated with values,

  • 0

I’ve got a page that contains two lists, one empty, one populated with values, both identical in structure. A user can select an item from the populated list, click a button, and it will move to the empty list via jQuery. When the form is submitted, I save all the option ids into a hidden form field to be later parsed out after post. However, when I submit the page, if I have moved a value from one listbox to the other, I encounter the following error (otherwise, the page posts normally):

System.InvalidOperationException: The parameter conversion from type 
'System.String' to type 'System.Web.Mvc.SelectListItem' failed because no type
 converter can convert between these types. at 
 System.Web.Mvc.ValueProviderResult.ConvertSimpleType(CultureInfo culture, Object value, Type destinationType) at 
 System.Web.Mvc.ValueProviderResult.UnwrapPossibleArrayType(CultureInfo culture, Object value, Type destinationType) at 
 System.Web.Mvc.ValueProviderResult.ConvertTo(Type type, CultureInfo culture) at 
 System.Web.Mvc.ValueProviderResult.ConvertTo(Type type) at 
 System.Web.Mvc.DefaultModelBinder.ConvertProviderResult(ModelStateDictionary modelState, String modelStateKey, ValueProviderResult valueProviderResult, Type destinationType)

Here is the relevant code:

ViewModel:

public class ViewModel
{
    public IEnumerable<SelectListItem> currentUsers { get; set; }
    public IEnumerable<SelectListItem> availableUsers { get; set; }
}

Initial Controller Action:

public ActionResult Index() 
{
    IEnumerable<User> availableUsers = SomeDal.GetUsers();

    var model = new ViewModel 
    {
        currentUsers = Enumerable.Empty<User>().Select(x => new SelectListItem
        {
            Value = x.id.ToString(),
            Text = x.name
        }),

        availableUsers = availableUsers.Select(x => new SelectListItem
        {
            Value = x.id.ToString(),
            Text = x.lastName
        })
    };
}

POST Controller Action:

[HttpPost]
public ActionResult Index(ViewModel model) 
{
    // at this point, ModelState.IsValid is already true, so I figure the rest of this isn't necessary
}

The jQuery that moves items:

$('#swapUsers').click(function () {
    $('#availableUsers option:selected').appendTo('#currentUsers');
});

The ListBoxes::

@Html.ListBox(
         "currentUsers",
         new SelectList(Model.currentUsers, "value", "text"),
         new { @class = "listbox" }
         )

@Html.ListBox(
         "availableUsers",
         new SelectList(Model.availableUsers, "value", "text"),
         new { @class = "listbox" }
         )

I had thought at first it was because of my strange Enumerable.Empty call, but the error occurs even if the currentUsers IEnumerable contains data.

EDIT 1:

HTML Pre-Post

<select class="listbox" id="currentUsers" multiple="multiple" name="currentUsers"></select>
<select class="listbox" id="availableUsers" multiple="multiple" name="availableUsers">
    <option value="1">Test User 1</option>
    <option value="2">TestUser2</option>
</select>

HTML Post-Post

<select class="input-validation-error listbox" id="currentUsers" multiple="multiple" name="currentUsers">
    <option selected="selected" value="1">Test User 1</option>
</select>
<select class="listbox" id="availableUsers" multiple="multiple" name="availableUsers">
    <option value="2">TestUser2</option>
</select>
  • 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-23T08:17:42+00:00Added an answer on May 23, 2026 at 8:17 am

    Keep in mind that the model that is getting posted to the server when the form is submitted will only include the list of selected values; You don’t show/say, but it sounds like your action on submit is accepting the same ViewModel as the one you are using to display the form. The ViewModel class has IEnumerable for each of the properties, and the error you are getting is because the ModelBinder can’t convert a list of strings to an IEnumerable<User> (or IEnumerable<SelectListItem>…A bit confused about that difference; Maybe your Model coming in (or parameters) to the method has an IEnumerable<SelectListItem>?).

    Really, the form submission should have a model coming in that accepts the two lists (or actually it probably only needs the currentUsers list) as a list of integers (or whatever the actual type is).

    public ActionResult PostMethod(IEnumerable<int> currentUsers)
    {
        ...
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

That's pretty much it. I'm using Nokogiri to scrape a web page what has
I've got a string that has curly quotes in it. I'd like to replace
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I'm making a simple page using Google Maps API 3. My first. One marker
link Im having trouble converting the html entites into html characters, (&# 8217;) i
Basically, what I'm trying to create is a page of div tags, each has
I have a French site that I want to parse, but am running into
I need to clean up various Word 'smart' characters in user input, including but
We are using XSLT to translate a RIXML file to XML. Our RIXML contains
i got an object with contents of html markup in it, for example: string

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.