I am trying to use a ClientTemplate containing a DropDownListFor in a grid. My ClientTemplate code is as follows:
@(Html.Kendo().DropDownListFor(m => m)
.DataValueField("Value")
.DataTextField("Text")
.Name("PurchaseAgreementType")
.BindTo(new List<SelectListItem>() {
new SelectListItem() {
Text = "PO Only",
Value = "PO Only"
},
new SelectListItem() {
Text = "Contract Based",
Value = "Contract Based"
}
}))
the column in the grid is shown here:
columns.Bound(l => l.PurchaseAgreementType).ClientTemplate("#=PurchaseAgreementType.Value#").Width(150);
This results in the following error: Uncaught TypeError: Cannot read property 'Value' of null
However if I copy/paste the code in the client template directly onto my form, it works perfectly.
How can I get this to work in my grid? It seems that the DDL is not populating.
Thanks.