[RESOLVED]Getting values from a Listbox( in PartialView) being delivered in view by Html.Action, in controller HTTP Post method

How do
I access the values of ListBox in partialview being delivered by Html.Action, in controller HTTP Post method

View

<div
class="form-horizontal"><div
class="form-group"><label
class="control-label
col-xs-2">
Worker:
</label>@Html.Action("WorkerListPartial",
"WorkerTask")</div></div>

PartialView

@model Actreve.Models.WorkersViewModel
<div class="well">
    <div class="container">
        <div class="row alert-info">
            @Html.ListBoxFor(m => m.worker, Model.WorkersList, new { size = 5, data_placeholder="Select worker.." })
            </div></div></div>
   public class WorkersViewModel
    {
      public string WorkerName { get; set; }
      public int WorkerId { get; set; }
      public IEnumerable<string> worker { get; set; }
      public  List<SelectListItem> WorkersList{get; set;}



        public WorkersViewModel()
        {
            WorkersList = new List<SelectListItem>();
        }
    }
}

Thanks for your help,

Rose :)

for the binder to work, it need to a concrete class to create an item, change

public IEnumerable<string> worker { get; set; }

to

public List<string> worker { get; set; }

Leave a Reply