Anokrize Anokrize - 3 months ago 18
ASP.NET (C#) Question

Telerik Grid Custom Dropdown doesn't take value

I am having a problem setting up my Telerik KendoUI Grid for Asp.net MVC.
Inside my grid I have linked up a custom kendo DropDownList.

The list looks like this:

@(Html.Kendo().DropDownList()
.BindTo(new List<SelectListItem>() {
new SelectListItem()
{
Text = "A",
Value = "Anrufen"
},
new SelectListItem()
{
Text = "BT",
Value = "nächster Beratungstermin"
},
new SelectListItem()
{
Text = "PT",
Value = "Probetraining"
},
new SelectListItem()
{
Text = "V",
Value = "Verloren"
}
})
.DataValueField("Value")
.DataTextField("Text")
.Name("Ergebnis")
)


I bound it to the Telerik Grid Column like that:

columns.Bound(product => product.Aktion).EditorTemplateName("AktionTemplate").Title("Ergebnis");


Everythin works fine and the DropDown list gets displayed except that the grid doesn't take the value from the selected list element.

When I select anything from the dropdown and trying to save it, then there is no value, it is null.

EDIT:
Controller/Action:


public ActionResult Details(int id)
{
KundeContext kundeContext = new KundeContext();
var result = kundeContext.Kundes.Where(x => x.KdNr == id).FirstOrDefault();

return View(result);
}


Calling Method(AngularJS):

$scope.Select = function (x) {
window.location = "http://localhost:50380/Kunde/Details/" + x;
}

Answer

From Documentation on Editor Templates.

The name of the widget should be the same as the name of the property.

Try changing the Name property of your dropdownlist to 'Aktion' instead of 'Ergebnis'.

Comments