R
Ryan
I have a dropdown list bound to a datasource. I would like to clear it
at the press of a button. I tried using the following code:
mydropdown.Items.Clear()
The end result is that it comes back unchanged.
I then thought to myself maybe it has to do with the viewstate so I I
kept adding more and more code until I ended up with the following:
ViewState.Clear()
ClearChildViewState()
mydropdown.AutoPostBack = False
mydropdown.EnableViewState = False
mydropdown.Items.Clear()
Again, I just got my orignal list back. So does items.clear() not have
an effect on the control once it has been databound the very first
time.
Additionally, is it better to loop through all my controls and blank
them out, which would, if there is no fast method of clearing a drop
down list, mean looping through and removing each item from the drop
down list, OR to response.redirect back to my page. When I say better
I mean faster to the end-user...
Thanks,
Ryan
at the press of a button. I tried using the following code:
mydropdown.Items.Clear()
The end result is that it comes back unchanged.
I then thought to myself maybe it has to do with the viewstate so I I
kept adding more and more code until I ended up with the following:
ViewState.Clear()
ClearChildViewState()
mydropdown.AutoPostBack = False
mydropdown.EnableViewState = False
mydropdown.Items.Clear()
Again, I just got my orignal list back. So does items.clear() not have
an effect on the control once it has been databound the very first
time.
Additionally, is it better to loop through all my controls and blank
them out, which would, if there is no fast method of clearing a drop
down list, mean looping through and removing each item from the drop
down list, OR to response.redirect back to my page. When I say better
I mean faster to the end-user...
Thanks,
Ryan