Click here to Skip to main content
15,908,455 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Hi
i have 2 dropdown with onselectedindexchanged and autopostback true

when i click dropdown1 the page reloads ,and current select listitem is default in selectbox.., i fill dropdown2 from database depending on dropdown1 value..
then when i click dropdown2 ,page reloads but the dropdown2 selected index remains 0 or blank


what is error


XML
<asp:DropDownList ID="DropCity"  AutoPostBack="True"   onselectedindexchanged="DropCity_SelectedIndexChanged"   runat="server" >
                    </asp:DropDownList>




XML
<asp:DropDownList ID="DropCity1"  AutoPostBack="True"   onselectedindexchanged="DropCity1_SelectedIndexChanged"   runat="server" >
                    </asp:DropDownList>




C#
protected void DropCity1_SelectedIndexChanged(object sender, EventArgs e)
  {


DropCity.DataSource();
DropCity.databing();



}

C#
protected void DropCity_SelectedIndexChanged(object sender, EventArgs e)
    {



}


please advice
Posted
Updated 31-Jan-14 0:03am
v3
Comments
DipsMak 31-Jan-14 5:55am    
you are having issues with checkbox or dropdowns..????
maulikshah1990 31-Jan-14 6:01am    
updated question...pls check
Bojjaiah 31-Jan-14 6:47am    
1) Check isPostback is there not in you Page_Load()?
2) other wise post you full of code

Bind the values to drp2 in drp1's SelectedIndexChanged event..
If you not doing any operation on drp2 index changed event then set autopostback = "false"

make use of properties as below


C#
drp1.DataTextField = "Test1";
               drp1.DataValueField = "TestID";
               drp1.DataSource = dt;

               drp1.DataBind();
 
Share this answer
 
set autopostback =fasle for dropcity1
 
Share this answer
 
Hi i solved it.. i check in DropCountry , if Dropcity is null ,then only fill it..
so this runs now
 
Share this answer
 
Comments
Sergey Alexandrovich Kryukov 10-Mar-14 0:48am    
Not an answer.
—SA

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