我有这段代码,如何将Value属性设置为DataSource中的第一个元素?
@(Html.Kendo().ComboBox()
.Name("cboShip")
.Placeholder("Select Ship...")
.Filter(FilterType.Contains)
.DataTextField("ShipName")
.DataValueField("ShipId")
.DataSource(s =>
{
s.Read(read => { read.Action("GetShips", "Filter"); });
})
.Events(events => events.Change("cboShipMultiChange"))
.Value('' /*????? I want to get the first element from the DataSource and use it in here*/)
)
答案 0 :(得分:1)
根据我的评论:
您应该只可以应用.SelectedIndex(0)而不是值。在声明中
@(Html.Kendo().ComboBox()
.SelectedIndex(0) //or whatever index you want to apply.
....... removed for brevity
)