This is a migrated thread and some comments may be shown as answers.
DropDownListFor Initial Value Incorrect
1 Answer 49 Views
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Top achievements
Rank 1
GT asked on 08 Dec 2011, 11:39 PM
Telerik Version 2011.3.1115

This appears to be the same problem as discussed in a previous post, however, the DropDownListFor method does not appear to properly select the initial value of Model.MySelectedValue.

var items = new List<object>
          new { Name = "Option A", Value = MyEnum.A},
          new { Name = "Option B", Value = MyEnum.B},
          new { Name = "Option C", Value = MyEnum.C},
          new { Name = "Option D", Value = MyEnum.D},
viewModel.MySelectList = new SelectList(items , "Value", "Name");
viewModel.MySelectedValue = MyEnum.C;
return View(viewModel);

@Html.DropDownListFor(o => o.MySelectedValue, Model.MySelectList)
@Html.Telerik().DropDownListFor(o => o.MySelectedValue).BindTo(Model.MySelectList)

The standard html drop down list properly selects the 'Option C' value, whereas the Telerik drop down list does not.

Happy to upload a sample if necessary, its pretty easy to reproduce.

1 Answer, 1 is accepted

Sort by
Telerik team
answered on 09 Dec 2011, 03:57 PM
Hello Greg,

You could use the Value property to set the initially selected value of the DropDownList. For example:
    Html.Telerik().DropDownListFor(o => o.MySelectedValue)

Best wishes,
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the Telerik Extensions for ASP.MET MVC, subscribe to their blog feed now
Asked by
Top achievements
Rank 1
Answers by
Telerik team
Share this question