MultiSelect does not submit

2 posts, 0 answers
  1. Anders
    Anders  avatar
    2 posts
    Member since:
    Oct 2012

    Posted 07 Mar 2017 Link to this post

    I am trying to get a MultiSelect to submit but it just refuse.

    I am trying to debug the incoming request from the page and it contains no selectlist value in any way, shape or form.

                    <div class="demo-section k-content">
                        @(Html.Kendo().MultiSelectFor(x => x.CMC)
                              .ValuePrimitive(true)
                              .BindTo(ViewBag.CMC)
                              .DataTextField("Name")
                              .DataValueField("UnitId")
                              .Filter(FilterType.Contains)
                              .Placeholder("Välj ett eller flera CMC...")
                        )
                    </div>

    This is inside a using block that looks like this:

        @using (Html.BeginForm("Search", "Search"))
        {

        }

    The model (SearchABR) is fetched from the viewbag as you can see above, and looks like this:

        public class SearchABR
        {
            public string Abonnentnummer { get; set; }
            public string Firstname { get; set; }
            public string Lastname { get; set; }
            public List<CMCEntity> CMC { get; set; }
        }

    And in this function in the controller:

            [Authorize(Roles = "ABR_LOGIN")]
            [HttpPost]
            public ActionResult Search(SearchABR search)
            {
                RetreiveInformation ri = new RetreiveInformation();
                if (ModelState.IsValid)
                {
                    // Everything is valid. Return the search parameters.
                    // Fix CMC information.
                }

                ViewBag.CMC = FetchCMC();
                return View(search);
            }

    And I put a breakpoint at "Fix CMC Information" and cannot find CMC in the Request at all. It's not there. The other fields are there, but not CMC.

    Help!

  2. Anders
    Anders  avatar
    2 posts
    Member since:
    Oct 2012

    Posted 09 Mar 2017 in reply to Anders Link to this post

    I fixed the problem.

    The form tag was nestled into a table and that's not allowed, thus it didn't submit.

Back to Top