简体   繁体   English

如何将kendoui下拉列表的选定值绑定到我的模型?

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

I have a KendoUI dropdownlist as follows: 我有一个KendoUI下拉列表如下:

@(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. 我必须使用DropDownListFor而不是DropDownList,加上.Name属性必须匹配模型的Id。

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

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何验证DropDownList中的选定值? - How do I validate a selected value in a DropDownList? 如何将数据表绑定到模型,然后绑定到MVC中的dropdownlist? - How do I bind a datatable to model and then to a dropdownlist in mvc? ASP如何在详细信息视图中绑定下拉列表的选定值 - ASP How to bind the selected value of a dropdownlist in detailsview 将下拉列表选择的值及其文本框值绑定到Model MVC5 - Bind the dropdownlist selected value and its textbox value to Model MVC5 如何将模型值绑定到dropdownlist mvc4中的选定项文本 - how to bind model value to selected item text from dropdownlist mvc4 如何将数据绑定到asp.net中另一个dropdownlist的选定值上的dropdownlist? 我已经将数据绑定到所有下拉列表 - how to bind data to the dropdownlist on selected value of the other dropdownlist in asp.net?? I have already bind data to the all the dropdown 如何获取从数据库填充的下拉列表的选定值? - How do I get the selected value of a dropdownlist populated from a database? 如何在MVC中获取DropDownList的选定值 - How do I get the selected value of a DropDownList in MVC 如何基于使用ajax从另一个下拉列表中选择的值来更改下拉列表中的选项? - How do I change the options from a dropdownlist based on the selected value from another dropdownlist using ajax? 如何将文本框绑定到下拉列表? - How do I bind the textbox to a dropdownlist?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM