Select default item from the dropdownlist if Item count is 1

3 posts, 0 answers
  1. Amol
    Amol avatar
    4 posts
    Member since:
    Apr 2013

    Posted 29 Jul 2013 Link to this post


    I have a cascading dropdownlist,  and if the Item count for the dropdown getting populated is 1 I want to keep the item it default selected instead of showing OptionLabel and the item. Or else remove the Option label in that case. below of the my dropdown which gets populated on change of dropdown 'DeliveryDestinationID'. How do i do this.

                                          .HtmlAttributes(new { style = "width:235px" })
                                          .OptionLabel("Select Delivery Name...")
                                         .DataSource(source =>
                                              source.Read(read =>
                                                  read.Action("GetDeliveryNames", "DeliveryQueue")

  2. Dimiter Madjarov
    Dimiter Madjarov avatar
    2215 posts

    Posted 31 Jul 2013 Link to this post

    Hello Amol,

    This is a quote from my answer in the support thread:

    To achieve this you could bind to the dataBound event of the DropDownList and check the length of the dataSource data. If there is only one item, you could select it.
    .Events(e => e.DataBound("dataBound"))

    function dataBound(e) {
        var ds =;
        if (ds.length == 1) {

    Please post your questions only once, so we could provide you the best possible assistance. I wish you a great day!


    Dimiter Madjarov
    Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
  3. Luiz
    Luiz avatar
    4 posts
    Member since:
    Apr 2012

    Posted 12 Jan in reply to Dimiter Madjarov Link to this post

    Or you could simply do:

    if ( > 0);


Back to Top