This is a migrated thread and some comments may be shown as answers.

Dropdown List not selecting initial value/text

1 Answer 194 Views
DropDownList
This is a migrated thread and some comments may be shown as answers.
Sam
Top achievements
Rank 1
Sam asked on 02 Apr 2015, 04:53 AM


The following dropdownlist will not ever select any item except for the first (index 0):

  var clientList = HtmlExtensionMethods.GetClients().Select(c => new SelectListItem { Text = c.Value, Value = c.Key }).ToList();

 @(Html.Kendo().DropDownListFor(model => model.ClientID)
    .Name("ClientID")
    .BindTo(clientList)
    .DataTextField("Text")
    .DataValueField("Value")
    .Value(Model.ClientID)
    .Text(Model.ClientName)
    .HtmlAttributes(new { @class = "select wfull" })
  )

I have tried removing the Value and Text methods and adding .SelectedIndex(2) which does not work either.  The model.ClientID is a value in the selectlistitem.  How in the world can I get this dropdown to select the item with the value from model.  Nothing seems to work.

 v2014.3.1314



1 Answer, 1 is accepted

Sort by
0
Boyan Dimitrov
Telerik team
answered on 03 Apr 2015, 04:14 PM

Hello Sam,

I attached a very similar project that should select by default the third item (Grey) in the drop down list. Please review the project and let us know how that worked.

Regards,
Boyan Dimitrov
Telerik
 

See What's Next in App Development. Register for TelerikNEXT.

 
Tags
DropDownList
Asked by
Sam
Top achievements
Rank 1
Answers by
Boyan Dimitrov
Telerik team
Share this question
or