Click here to Skip to main content
15,887,214 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Hi..

Following is my code,even though am using update panel for dropdownlist its getting reset after i select different value:-

C#
<asp:UpdatePanel runat="server" UpdateMode="Always" ChildrenAsTriggers="true">
                   <ContentTemplate>
                       City:
                       <asp:DropDownList ID="ddlCity" runat="server" AutoPostBack="true" OnSelectedIndexChanged="ddlCity_SelectedIndexChanged">
                       </asp:DropDownList>
                   </ContentTemplate>
                   <Triggers>
                       <asp:AsyncPostBackTrigger ControlID="ddlCity" EventName="selectedindexchanged" />

                   </Triggers>
               </asp:UpdatePanel>


Please let me know,wat am i missing?

Thank you.
Posted
Updated 31-Jul-13 20:48pm
v2
Comments
VICK 1-Aug-13 2:46am    
Have you tried using EventName = "SelectedIndexChanged" or EventName="IndexChanged" ???

if you loading your dropdown dynamically using c# code then try this

C#
protected void Page_Load(object sender, EventArgs e)

{

if (IsPostBack)
    {
//code to load yo dropdown

    }
}


OR

C#
if (!IsPostBack)
    {
//code to load yo dropdown

    }


Then you can set AutoPostBack="true" for yo control.

It worked for me.
 
Share this answer
 
Make AutoPostBack="true" as False
 
Share this answer
 
Comments
bhagyap 1-Aug-13 2:37am    
Tried it.. But the exception still persists.
XML
In Trigger
<asp:AsyncPostBackTrigger ControlID="ddlCity" EventName="SelectedIndexChanged"/>

in cs you must have
protected void ddlCity_SelectedIndexChanged(object sender, EventArgs e)
{

}
 
Share this answer
 
v2
Comments
bhagyap 1-Aug-13 2:40am    
ya i have it in cs but still the exception persists. Please let me know what i might be missing.
OnSelectedIndexChanged its calling a method "ddlCity_SelectedIndexChanged".
make sure that it exist in code behind.

or if you don't need anything to be done on selected index changed event just remove
OnSelectedIndexChanged="ddlCity_SelectedIndexChanged"
 
Share this answer
 
Comments
bhagyap 1-Aug-13 2:45am    
ok.. but what i have to do with the dropdown which is resetting?
Adarsh chauhan 1-Aug-13 2:48am    
set AutoPostBack="False" for dropdownlist

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