How to link data from Telerik ComboBox to my data model

Why won't my Telerik ComboBoxFor bind my value and populate my ComboBox through AJAX?

@using (Html.BeginForm()) {
@Html.ValidationSummary(true)
<fieldset>
    <div class="editor-field">
        @Html.EditorFor(model => model.Name)
        @Html.ValidationMessageFor(model => model.Name)
    </div>
    <div class="editor-field">
    @(Html.Telerik().ComboBoxFor(model => model.VendorId)
        .Name("ddlVendor")
        .ClientEvents(events =>
                          {
                              events.OnLoad("onVendorLoad");
                              //events.OnChange("onVendorChange");
                              events.OnDataBinding("onComboBoxDataBinding");
                          }
        )
        .DataBinding(bind => bind.Ajax().Select("_AjaxGetVendors", "Car"))
    )
    </div>
    <p>
        <input type="submit" value="" />
    </p>
</fieldset>}

In my controller, I get an object, but VendorId == 0.

 [HttpPost]
    public ActionResult Create(Car obj)
    {
            dm.InsertModel(obj);
            return RedirectToAction("Create");
    }
+5
source share
1 answer

Option 1

Remove .Name("ddlVendor")from your ComboBox if you do not need it.

Option 2

Rename your ComboBox as follows and update the client event links for the control:

.Name("VendorId") 
+5
source

All Articles