I am using a kendo UI DropDownList control, how can we set a default value to the DropDownList?
I have a selected list property in viewmodel as following :
public SelectList AuditTypes { get; set; }
Then in controller I am populating the selected list and setting it to a default value
viewModel.AuditTypes = new SelectList(dropdownDetails, "Value", "Text", dropdownDetails.Where(x => x.Default == true));
and in my razor view I have the following code :
@(Html.Kendo().DropDownList()
.Name("AuditType")
.DataTextField("Text")
.DataValueField("Value")
.BindTo(Model.AuditTypes)
.AutoBind(true)
The problem is that the default value is not being set.
DropDownListFor(x=>x.value)
version, so Longball27's suggestion is valid (and preferable in Razor). – Poetics