Clearing a datasource for a dropdown list

mrsgrams1

Newcomer
Joined
Aug 29, 2003
Messages
4
Location
Fargo, ND
I have an ASP.Net form that I am working on. There are three dropdown lists. The first is the company. Once the company is selected, the 2nd (department) dropdown list is filled appropriately. If the company selection changes, the controls are set to postback to the server, and the datasource for the department drop down list is a view on a dataset. This part is working just fine. The 3rd dropdown(area) is also filled the same way. When a department selection is made, the area is filled acccordingly using a view of a dataset.

The part I am wondering about is when the company is changed to a selection where no departments exist. The department drop down list clears out to nothing just fine, but the area dropdown stays at what it was. I am trying to get it so that the area dropdown list clears out completely until a department is selected again after the company selection changes.
 
I figured it out...

If anyone is interested...I figured it out!

This is what I was missing:

lstArea.Items.Clear()

I needed to clear the items collection each time the company selection was changed. Works like a charm now.
 
Back
Top