2
@(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 = "" })
)
をモデル化するために選択された値を結合しない
しかし、どのアイテムを選択しても、ServiceID
フィールドは常にnullです! nullable型でもないint?
!
どうして私は何が起きているのですか?
解決策ありがとうございました!私を混乱させるただ一つの事は、DataValueField()はどういう意味ですか?私はそれが選択された値として使用されているフィールドを定義していると思ったが、選択された値は常に(テキスト、値)ペアですか? – shole
理想的には、DataValueFieldを設定すると、ペアの代わりに値を取得する必要があります。残念ながら、それはしません。私はそれも私が最初に混乱していることに同意します。 – Win