Using ddl.Items.Clear() will clear the drop-down list, however you must be sure that your drop-down list is not configured to:
AppendDataBoundItems="True"
This option will add the bounce data to the existing list, which will NOT be cleared before binding.
Decision
Add AppendDataBoundItems="False" to the drop-down list.
Now that the data is being restored, it will automatically clear all existing data.
Protected Sub ddl1_SelectedIndexChanged(sender As Object, e As EventArgs) ddl2.DataSource = sql2 ddl2.DataBind() End Sub
NOTE. . This may not be acceptable in all situations, since appenddatbound elements can cause the drop-down list to add its own data each time the list changes.
TOP TIP
Still want the default list item to add to the drop-down list, but do you need to reset the data?
Use AppendDataBoundItems="False" to prevent data duplication during AppendDataBoundItems="False" , and then immediately after binding your drop-down list, insert a new default list item.
ddl.Items.Insert(0, New ListItem("Select ...", ""))
source share