I want to have the dropdown default select a value. I have the value is in a ViewData. How can I access this from javascript?
@(Html.Kendo().DropDownList()
.Name("locationCode")
.HtmlAttributes(new { style = "width:200px" })
.DataValueField("Code")
.DataTextField("Name")
.DataSource(source =>
{
source.Read(read =>
{
read.Action("GetUserGlobalDimensions", "RequestPONumber");
});
}
)
.Events(e => { e.DataBound("onLocationDataBound"); })
In js file:
function onLocationDataBound() {
this.value('ViewData["defaultLocationValue"]');
}
Thanks in advance.
@(Html.Kendo().DropDownList()
.Name("locationCode")
.HtmlAttributes(new { style = "width:200px" })
.DataValueField("Code")
.DataTextField("Name")
.DataSource(source =>
{
source.Read(read =>
{
read.Action("GetUserGlobalDimensions", "RequestPONumber");
});
}
)
.Events(e => { e.DataBound("onLocationDataBound"); })
In js file:
function onLocationDataBound() {
this.value('ViewData["defaultLocationValue"]');
}
Thanks in advance.