We help IT Professionals succeed at work.
Get Started

show all selected options in Multiselect mvc c# after the submit

lulu50 asked
Last Modified: 2020-02-08

How can I show all selected items after the submit?

Can someone help me and tell me what I'm doing wrong please?

Model :

        public IEnumerable<SelectListItem> VersionList { get; set; }

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

      public IEnumerable<SelectListItem> GetVersion()
            var GetVersion = _unitOfWorkCABusinessRules.RuleDetailRepo.GetAll().GroupBy(x => x.Version).Select(y => y.First()).Distinct();

            return GetVersion
                 .Select(x => new SelectListItem
                     Text = x.Version,
                     Value = x.Version.ToString(),
                .OrderBy(x => x.Text);

Open in new window


  public ActionResult SearchRules(CABRSearchRules model, string[] SelectedVersion)

              model.VersionList = _careAdvanceBusinessRulessService.GetVersion();
            model.SelectedVersion = SelectedVersion.ToList();

      return View(model);

Open in new window

            onInitialized: function (option, checked) {
                var values = [];
                var dropdown = $('#SelectedVersion').siblings('.multiselect-container');
                $('#SelectedVersion option').each(function () {
            enableFiltering: true,
            buttonWidth: '350px',
            maxHeight: 200,
            enableCaseInsensitiveFiltering: true,

 @Html.DropDownListFor(m => m.SelectedVersion, new SelectList(Model.VersionList, "Value", "Text"), new { @multiple = "multiple" } )

Open in new window

Watch Question
Systems architect
Top Expert 2006
This problem has been solved!
Unlock 1 Answer and 4 Comments.
See Answer
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant

An Experts Exchange subscription includes unlimited access to online courses.

Get Started
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE