Property selected in SelectedListItem is not working after pass it to DDL control

2 posts, 0 answers
  1. Mateusz
    Mateusz avatar
    13 posts
    Member since:
    Jan 2015

    Posted 15 Dec 2015 Link to this post


    I have DropDownList control which looks: 

    @(Html.Kendo().DropDownListFor(m => m.VatCategoryId)
                   .DataSource(source =>
                       source.Read(read =>
                           read.Action("GetVatCategoriesDefault", "VAT").Data("getCountry").Type(HttpVerbs.Get);

    In read method I am passing a list with categories. Some I want one of the item be selected. So I set property Selected = true in SlectedListItem. 

    Data which view is receiving are good but the default category is not selected. 

    What could be wrong? 





  2. Nencho
    Nencho avatar
    1446 posts

    Posted 16 Dec 2015 Link to this post

    Hello Mateusz,

    I am afraid that the DropDownList cannot directly communicate with the dynamically assigned datasource and read the object's list properties (selected in this case) and perform action base on their values.
    This is why, I would suggest you to handle the dataBound event of the control an iterate though the items collection, in order to find the item with the Selected property set to true and set it as selected.

    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
  3. UI for ASP.NET AJAX bannerTelerik UI for ASP.NET Core is out
Back to Top