How to set default value for kendo ui dropdown list?

I am using the DropDownList control for kendo UI, how can we set the default value for DropDownList?

I have a property of the selected list in the viewmodel as shown below:

public SelectList AuditTypes { get; set; } 

Then in the controller I populate the selected list and set its default value

 viewModel.AuditTypes = new SelectList(dropdownDetails, "Value", "Text", dropdownDetails.Where(x => x.Default == true)); 

and in my razor mode 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 set.

+8
kendo-ui kendo-dropdown
source share
1 answer

Just guess, try .Value (YOUR_VALUE) in your chain

http://docs.kendoui.com/api/web/dropdownlist#configuration-value

Note. - Be sure to pass the ValueField value, not TextField in the .Value () property of Kendo Control, since "YOUR_VALUE" must be an integer property, since .Value () accepts an integer, not a text property, otherwise it will not work, it will not will show no errors, but it will not give the desired result.

+3
source share

All Articles