This is a migrated thread and some comments may be shown as answers.

MultiSelect does not submit

1 Answer 116 Views
MultiSelect
This is a migrated thread and some comments may be shown as answers.
Anders
Top achievements
Rank 1
Anders asked on 07 Mar 2017, 02:49 PM

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!

1 Answer, 1 is accepted

Sort by
0
Anders
Top achievements
Rank 1
answered on 09 Mar 2017, 09:38 AM

I fixed the problem.

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

Tags
MultiSelect
Asked by
Anders
Top achievements
Rank 1
Answers by
Anders
Top achievements
Rank 1
Share this question
or