Anokrize Anokrize -4 years ago 214
ASP.NET (C#) Question

Terik Grid Dropdown Column

I know that there are some examples from Telerik but I don't quite understnad them. You can see my code below. What am I doing wrong?

Snippet of grid:

.Columns(columns =>
columns.Bound(product => product.Id).Hidden();
columns.Bound(product => product.KdNr);
columns.Bound(product => product.Datum).Format("{0:dd.MM.yyyy}");
columns.Bound(product => product.Aktion);
columns.Bound(product => product.Ergebnis).EditorTemplateName("ErgebnisTemplate.cshtml").Title("Ergebnis");
columns.Bound(product => product.Wiedervorlage).Format("{0:dd.MM.yyyy H:mm}");
columns.Bound(product => product.Bemerkung);
columns.Bound(product => product.Erledigt).ClientTemplate(
"<input type='checkbox' disabled='disabled'" +
"# if (Erledigt) { #" +
"checked='checked'" +
"# } #" +

Here you can see that the column "Ergebnis" which is the 5th column is bound to a custom template (

ErgebnisTemplate.cshtml (located in Views/Shared/EditorTemplates):

@using System.Collections
@model System.Int32

.BindTo(new List<SelectListItem>() {
new SelectListItem()
Text = "Anrufen",
Value = "A"
new SelectListItem()
Text = "Verloren",
Value = "V"

Answer Source

You don't need to put the .cshtml extension while specifying EditorTemplateName. Just EditorTemplateName("ErgebnisTemplate") is enough.

Since MVC is following conventions over configuration approach, it will automatically search for the razor file with the name provided in the EditorTemplateName method under the views folder

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download