Hi,
I am binding to an asp.net dropdownlist from a datasource. After the databind command, how do I remove an item from the drop down list?
I tried List.Items.Remove(“Please inquire”);
This didn’t work. Please help
Hi,
I am binding to an asp.net dropdownlist from a datasource. After the databind command, how do I remove an item from the drop down list?
I tried List.Items.Remove(“Please inquire”);
This didn’t work. Please help
You have to separate your code into a separate sub like this:
Sub Page_Load()
If Not IsPostBack Then
Call BindData()
End If
End If
Sub BindData()
...Code that binds to the datasource
End Sub
Sub DeleteFromDataSource()
...Code that removes from the datasource
Call BindData() ' This call will rebind the list
End Sub
Not sure why you want to bind an item then remove it immendiately but you can do it like you were trying initially. However remove() takes a ListItem param not a string so you would need to use.
[size=2]List.Items.Remove(List.Items.FindByText("Please inquire"));
[/size]
that worked greatly. Thanks so much