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

RadDropDownList items.clear() is not working

1 Answer 1108 Views
DropDownList
This is a migrated thread and some comments may be shown as answers.
HAN MING
Top achievements
Rank 1
HAN MING asked on 06 Sep 2016, 02:58 AM

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? 

1 Answer, 1 is accepted

Sort by
0
Ivan Danchev
Telerik team
answered on 06 Sep 2016, 06:11 AM
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.
Tags
DropDownList
Asked by
HAN MING
Top achievements
Rank 1
Answers by
Ivan Danchev
Telerik team
Share this question
or