Dropdown List not selecting initial value/text

2 posts, 0 answers
  1. Sam
    Sam avatar
    6 posts
    Member since:
    Jan 2015

    Posted 01 Apr 2015 Link to this post



    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



  2. Boyan Dimitrov
    Admin
    Boyan Dimitrov avatar
    1746 posts

    Posted 03 Apr 2015 Link to this post

    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.

     
  3. UI for ASP.NET MVC is VS 2017 Ready
Back to Top