RadDropDownList items.clear() is not working

2 posts, 0 answers
  1. HAN MING
    HAN MING avatar
    4 posts
    Member since:
    Sep 2016

    Posted 05 Sep Link to this post

    Hi, 

    I trying to do a rest of DropDownList whenever my RadTabStrip is changing. I have try using Items.Clear() when there a TabSwitch Event occur. however, is not wroking.The Item in DropdownList is blinded with Datasource, try setting DataSource as Null is not working too.

    Can someone advise my an alternative solution? 

  2. Ivan Danchev
    Admin
    Ivan Danchev avatar
    832 posts

    Posted 06 Sep Link to this post

    Hello Han Ming,

    You can clear the DropDownList on tab selection either on the client or on the server. In order to do it on the server subscribe the TabStrip to the TabClick event and call the DropDownList's Clear() method in its handler:
    protected void RadTabStrip1_TabClick(object sender, Telerik.Web.UI.RadTabStripEventArgs e)
    {
        RadDropDownList1.Items.Clear();
    }

    On client you can use the OnClientTabSelecting event:
    function OnClientTabSelecting(sender, eventArgs) {
        var ddl =  $find("<%=RadDropDownList1.ClientID%>")
        ddl.get_items().clear();
        ddl.get_textElement().innerHTML = "";
    }

    If you are binding the DropDownList in the code behind, be sure you are not rebinding it after clearing its items, for example after the server-side TabClick fires.

    Regards,
    Ivan Danchev
    Telerik by Progress
    Do you need help with upgrading your ASP.NET AJAX, WPF or WinForms projects? Check the Telerik API Analyzer and share your thoughts.
  3. UI for ASP.NET Ajax is Ready for VS 2017
Back to Top