简体   繁体   English

asp剑道下拉默认值不使用定义的模板

[英]asp kendo dropdown default value not using defined template

My kendo dropdown menu's currently selected index will only show up as "ShortName". 我的剑道下拉菜单当前选择的索引只会显示为“ ShortName”。 If i expand the dropdown, it will correctly use the template "ShortName - Name". 如果我展开下拉菜单,它将正确使用模板“ ShortName-Name”。 Why is the template not being used on the currently selected index? 为什么在当前选定的索引上不使用模板?

@(Html.Kendo().DropDownList()
.Name("SiteId")
.DataTextField("ShortName")
.Template("#: ShortName # - #: Name #")
.DataValueField("Id")
.DataSource(source =>
{
     source.Read(read =>
     {
         read.Action("GetSites", "Home");
     });
})
)

You can use ValueTemplate same as Template . 您可以使用与Template相同的ValueTemplate

...
.Template("#: ShortName # - #: Name #")
.ValueTemplate("#: ShortName # - #: Name #")
...

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

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