Click here to Skip to main content
15,921,062 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Dear,

I am facing problem as follows describes bellow,
I have two drop-down control in asp.net page.
2nd one load based on first drop-down,when first one have only one data it is not fired & 2nd one not loaded.
I have tried first one fixed a item "--select--". now it's work but need appenddatabounditem true.
This cause problem,like when first drop-down 2 data,if i select first data,data loaded in 2nd drop-down,then 2nd data in first drop-down select then it will not clear previous data.i have tried items.clear this one but result is same.

Please can u help anyone to find out a way.

N:B: if needed more clarification in problem please comments.

Thanks in Advance
Mahmud
Posted
Comments
PrashantSonewane 15-Apr-13 0:30am    
instead of appenddatabounditem have you tried inserting "-Select-" like below:

DropDownList1.Items.Insert(0, "-Select-");
Mahmudunnabi 15-Apr-13 0:40am    
Dear,
is there any option to do it in aspx page.
Thanks
PrashantSonewane 15-Apr-13 0:31am    
can you add code how are you doing it now?

Try clearing the items and rebind it again.
In the SelectedIndexChanged event of first DropDownList clear the items of DropDownList2 and rebind that. Try this:
C#
protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e)
{
    if(DropDownList2.Item.Count > 0)
        DropDownList2.Items.Clear(); 
    //Now bind the data again to DropDownList2
}


Hope it helps!
--Amit
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900