Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Kendo MVC UI ComboBox Dictionary<int,string> Binding

How to bind type Dictionary to Kendo Combobox?

@(Html.Kendo().ComboBox()
.Name("Division")
.DataTextField("Key")
.DataValueField("Value")
.BindTo(Model.Filter.DivisionList)
)

Model.Filter.DivisionList is Dictionary With above code I have an error "not supported for serialization/deserialization of a dictionary, keys must be strings or objects."

Is there a simple workaround for this issue?

like image 782
Daniel G Avatar asked Oct 29 '25 11:10

Daniel G


1 Answers

This worked for me:

.Name("PaymentTerm"
).BindTo(
   new SelectList(Model.CreditCollectionInfo.PaymentTerms.Select(
         s => new {
             Key = s.Key, 
             Value = s.Value
         }
), "Key", "Value")
like image 117
Tim Avatar answered Nov 01 '25 12:11

Tim