Binding selected value of dropdownlist in editor template to model of main view

4 posts, 0 answers
  1. Kevin
    Kevin avatar
    2 posts
    Member since:
    Nov 2012

    Posted 16 Jul 2013 Link to this post

    I have a Kendo grid on one view that has a column that needs to be a dropdownlist when inline editing.  I've set the editor template name on the column to a partial view that I created, and that all seems to be working.

    The part that is not working is when you change the value of the dropdownlist and click the Update button in the command button column.  The selected value is not being applied to the model.
    @(Html.Kendo().DropDownList()
                .Name("divisionCombobox")
                .BindTo("#=UserViewModel.DivisionId")
                .HtmlAttributes(new { style = "width:250px" })
                .DataTextField("DisplayName")
                .DataValueField("Id")
                .AutoBind(true)
                .DataSource(source => source
                    .Read(read => read.Action("ListDivisions", "Security"))
                    .ServerFiltering(true))
    )

    Is the BindTo property not the right one to use?
  2. Kevin
    Kevin avatar
    2 posts
    Member since:
    Nov 2012

    Posted 16 Jul 2013 Link to this post

    Finally figured it out.  In case anyone else runs into this, the Name attribute of the control on the editor template needs to be the name of the model's property that you are trying to bind it to.
  3. Tamas
    Tamas avatar
    4 posts
    Member since:
    Nov 2015

    Posted 16 Feb 2016 in reply to Kevin Link to this post

    Thanks. This really helped me now!
  4. Tamas
    Tamas avatar
    4 posts
    Member since:
    Nov 2015

    Posted 16 Feb 2016 Link to this post

    Using 

    @(Html.Kendo().DropDownListFor(m => m.Property) ...

    works too. And there is no need to use the BindTo method.

Back to Top