sho*_*ole 4 c# asp.net-mvc kendo-asp.net-mvc
@(Html.Kendo().DropDownListFor(model => model.ServiceID)
.OptionLabelTemplate("#=optionLabel#")
.ValueTemplate("#=Code#(#=Rate#) - #=Description#")
.Template("#=Code#(#=Rate#) - #=Description#")
.DataTextField("Code")
.DataValueField("ServiceID")
.DataSource(d =>
{
d.Read(read =>
{
read.Action("GetServiceRepository", "Service").Type(HttpVerbs.Post);
});
})
.Events(e => e.Change("onWorkOrderJobServiceChange"))
.HtmlAttributes(new { required = "required" })
.OptionLabel(new { optionLabel = Resources.Wording.SelectOne, ServiceID = 0, Rate = 0, Code = "", Description = "" })
)Run Code Online (Sandbox Code Playgroud)
我有一个如上所述的下拉列表,并且想将所选值绑定到模型的ServiceID字段(类型为int)
但是,无论我选择哪一项,该ServiceID字段始终为空!它甚至不是可为空的类型int?!
为什么会发生这种情况以及我怎样才能实现我想要的目标?
Kendo DropDownList 有ValuePrimitive。默认情况下为 false,所选项目返回文本和值对。
@(Html.Kendo().DropDownListFor(model => model.ServiceID)
.ValuePrimitive(true)
....
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
3175 次 |
| 最近记录: |