Link to home
Start Free TrialLog in
Avatar of thesullyman
thesullyman

asked on

Clear Dropdownlist Selection and Previous Selection

I have a button and when i press it, it clears selections from my DropDownlist1. DropDownlist2 and Dropdownlist3. But how can i get it to clear the previous data chosen from the dropdownlists when i want display different data.

DropDownList1.ClearSelection()
        DropDownList2.ClearSelection()
        DropDownList3.ClearSelection()

If i select something from my dropdownlists and then i press my button and go to choose something else, my last chosen entries are still displayed under my dropdownlists. How do i totally clear these entries?

Thanks
Avatar of digitalZo
digitalZo
Flag of India image

You mean the Grid data displayed on previous button click?

On that Refresh button click along with DropDownList1.ClearSelection() also type, GridView1.Columns.Clear()
can u use DropDownListX.Items.Clear after clearselection?
Avatar of thesullyman
thesullyman

ASKER

Hi Digital,

Not the Grid data.

When i select something from the three dropdownlists, it displays my data in gridview.
Then i hit the refresh button to clear my selection and everything looks fine. The Dropdownlists return to choose client, choose city etc.
But when i look at the Choose City dropdownlist etc, it is still holding the options i chose in my previous selection

Does this make sense?
DropDownListX.Items.Clear will not work. This clears everything including the values in my dropdownlists
Any idea?
Okay, I get it. You mean the City Dropdownlist populates on the basis of Client dropdownlist and you don't want that? You want the default options to be there as on the Page Load?
Hi digital,

I think so

First dropdownlist containts clients etc.
Client 1
Client 2
Etc


Second Dropdwonlist contains Citys
City1
City2
Etc.

Third Dropdownlist contains Names
Name 1
Name 2
Etc.

If i choose, Client 1, then City 1,  then Name 1 - The Gridview is then displayed.

Now i want to get another client information so i hit Refresh button

So i choose, Client 2 etc. But under City, it is still holding my City1 option i chose earlier and the same under Name

Thanks
Avatar of Pratima
I ma not sure whther I got your question or not

But I think you are populating 2nd DropDown data Fron selected value for 1st Dropdown.........

So when next time you are selecting 1st dropdown all itms need to change from 2nd dropdown as per the selection of 1st ....right ?

is this is ths case then

on refresh button


DropDownList1.ClearSelection()
        DropDownList2.ClearSelection()
        DropDownList3.ClearSelection()


Only clear Items from 2nd & 3rd w
DropDownList2.Items.Clear
DropDownList3.Items.Clear
ASKER CERTIFIED SOLUTION
Avatar of Pratima
Pratima
Flag of India image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
thanks Pratima that worked so i will Mark Accept as solution.

I have just noticed another error now so i will post this new question soon. If someone picks something from Dropdownlist 2 and then changes their mind, the previous selection still says. I will give more detail in new question.

Thanks
glad you got your answer - which was what i said in the first place just not explicity saying list 2 and 3, sorry thought you would get what i was suggesting