Click here to Skip to main content
15,904,416 members
Please Sign up or sign in to vote.
2.50/5 (2 votes)
See more:
I have 2 dropdownlist .that second dropdown list receives value from first one to show data,but I have a problem that after fist selection from first dropdown seconde dropdown data can not refresh to gives new data from first drop down list,I used auto post back in first dropdown list but I dont know what can I write in selecting changes?
Posted
Comments
Ravi Sant 29-Nov-11 9:26am    
are you binding second dropdown on selectedIndexChange event of first dropdown? if so, that shall work..

You need to call DataBind() function while saving,updating or deleting data.
like
DropDownList.DataBind();
To get more reference Have a look there
MSDN-[DropDownList Class][^]
MSDN-[BaseDataBoundControl.DataBind Method][^]
 
Share this answer
 
Comments
kitykity 30-Nov-11 3:04am    
I write DropDownList.DataBind();
in first dropdownlist selecting change but it doesn't work
Well I am Not Sure.....about ur thing....
but this will work.....
try this one on Page load
<pre lang="c#">
protected void Page_Load(object sender, EventArgs e)
{
string s = DropDownList1.SelectedItem.ToString();

DropDownList2.Items.Add(s);

}
</pre>
 
Share this answer
 
Try to clear the old items of DropDownList before adding new Items in it.
C#
DropDownList1.Items.Clear();
 
Share this answer
 
Comments
kitykity 30-Nov-11 3:03am    
I used both DropDownList1.Items.Clear(); and DropDownList1.DataBinde(); but it desn't work

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