Click here to Skip to main content
15,920,217 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have used a DropDownList in UpdatePanel and i have handled SelectedIndexChanged and it is firing successfully, but in that i unable to get Correct SelectedValue, why..?
Here is my code
ASP.NET
<asp:UpdatePanel ID="NetworkUpadated" UpdateMode="Conditional" runat="server">
<ContentTemplate>
    NMI: <asp:TextBox ID="NMITextBox"  OnTextChanged="GetNetwork" AutoPostBack="true" runat="server"></asp:TextBox>

    Network Code:   <asp:DropDownList ID="NetworkCodeDropDown" AutoPostBack="true" OnSelectedIndexChanged="NetworkCodeDropDown_Changed" runat="server" > </asp:DropDownList>
  </ContentTemplate>
</asp:UpdatePanel>


and in my code behind
C#
public void NetworkCodeDropDown_Changed(object sender, EventArgs e)
       {
           string sel = NetworkCodeDropDown.SelectedValue;// it showing always 1
       }


If i check the request in Fidler it is going correct selected value,
but why i unable to get my selected value in code behind..
please help me
Posted
Updated 27-Jan-12 20:06pm
v2
Comments
Vikas_Shukla_89 28-Jan-12 2:25am    
heyyy, its working fine..
Just check ur "value" field of datasource.

hope, this help u..

1 solution

Yeah,
i got it,
I have done a bloody mistake that
am initializing DropDowns in Page_Load()
without checking Postback or not,
thats why (The Drop down values are again initializing so set to default value)
 
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