How do you bind on an edit form?

2 posts, 0 answers
  1. Myles
    Myles avatar
    18 posts
    Member since:
    Mar 2012

    Posted 14 Feb 2013 Link to this post

    I have an edit view for a particular model.  The view contains the following Kendo autocomplete control code:

     @(Html.Kendo().AutoCompleteFor(model => model.Location).Placeholder("Please select a value")
                   .Name("locationAutoComplete").BindTo((IEnumerable<LocationData>)ViewData["locationList"])
                   .DataTextField("Name")) //Specifies which property of the Product to be used by the autocomplete.
                   ;

    The drop down auto complete is working.  However, existing values on the model (Location property) are not bound to the control.  When I open up an existing record in edit mode the autocomplete control is empty, even if the underlying Location property on the model has a value.  How does this control handle binding?
  2. Daniel
    Admin
    Daniel avatar
    2117 posts

    Posted 18 Feb 2013 Link to this post

    Hello,

    The name is overridden with the Name method so the value will not be bound to a field named Location but locationAutoComplete. Removing the name should resolve the problem.

    Kind regards,
    Daniel
    the Telerik team
    Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
  3. UI for ASP.NET MVC is VS 2017 Ready
Back to Top