Combobox fails to post updated values after initial modelstate fail

3 posts, 0 answers
  1. Allan
    Allan avatar
    12 posts
    Member since:
    Oct 2012

    Posted 30 Aug 2017 Link to this post

    All our Combo Boxes are defined similar to this:

    @(Html.Kendo().ComboBoxFor(model => model.PortOfLoadingId)
        .Placeholder("Select port...")
        .DataSource(s =>
            s.Ajax().Read(r =>
                r.Action("GetComboBoxItems", "Ports");
        .Events(e => e.Select("portSelected"))
  2. Allan
    Allan avatar
    12 posts
    Member since:
    Oct 2012

    Posted 30 Aug 2017 in reply to Allan Link to this post

    Sorry, i can't edit top post which submitted by accident.

    When the user types an invalid value in the combo box field that does not match any of the items, and submits the form, the correct modelstate is generated saying the value is invalid.  The user is then directed back to the View:

                if (!ModelState.IsValid)
                    BeforeCreate(ref viewModel);
                    return View(viewModel);
    But no matter what the User does the ModelState will always be invalid for that combo box field.  Is this a bug since I thought changing the value again should clear the ModelState for that property?

  3. Ianko
    Ianko avatar
    1755 posts

    Posted 01 Sep 2017 Link to this post

    Hello Allan,


    Typically, changing the value of the ComboBox (from the UI) to a valid one should make the ViewModel valid. And process the form submission as usual.


    Can you please provide some more details about the validation and whether this is a simple form or an AJAX form? It would be best if you can provide a small example that can be locally run and examined.  


    Progress Telerik
    Try our brand new, jQuery-free Angular 2 components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
Back to Top