简体   繁体   中英

How do I bind the selected value of a kendoui dropdownlist to my model?

I have a KendoUI dropdownlist as follows:

@(Html.Kendo().DropDownList()
                                  .Name("DeviceInterfaces")
                                  .OptionLabel("Select interface...")
                                  .DataTextField("Name")
                                  .DataValueField("Id")
                                  .DataSource(source => source.Read(read => read.Action("GetCascadeDeviceInterfaces", "EventTriggers")))
                            )

It's a cascading dropdownlist, how do I set whatever the user selects to the property of my model?

It's ok, I found out how to.

I have to use DropDownListFor instead of DropDownList, plus the .Name property has to match the Id of the model.

@(Html.Kendo().DropDownListFor(m => m.EventTrigger.TriggerType)
.Name("EventTrigger.EventType")

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM