Dropdownlist binding data again on postback even with Page.IsPostback
<p>I need to have a dropdown with all the stores listed. and when clicked need to get the selected value but postback happens and even when i check Page.IsPostback it is always null because there are no data.</p>

<p>here is my code.</p>

<p>=============================================</p>

<h1>Here is my aspx file</h1>

<pre><code>&lt;div id="SurveyCompetitionContainer"&gt;
    &lt;div class="surveyCompetitionContents"&gt;
        &lt;ajax:UpdatePanel ID="WinSurveyAjax" runat="server" UpdateMode="conditional" ChildrenAsTriggers="true"
            RenderMode="block"&gt;
            &lt;ContentTemplate&gt;
                &lt;div id="competitionInfo" runat="server" visible="true"&gt;
                    &lt;div class="headerTitle"&gt;
                        Enter your email for the chance to win a week long holiday in a luxury apartment
                        in the Lake District.
                    &lt;/div&gt;
                    &lt;div class="emailBox"&gt;
                        &lt;div class="emailDiv"&gt;
                            &lt;asp:Label ID="emailLabel" CssClass="emailLabel" Text="Email:" runat="server"&gt;&lt;/asp:Label&gt;
                            &lt;asp:TextBox ID="emailTextbox" runat="server" CssClass="water" Text="" ClientIDMode="Static"
                                ValidationGroup="EmailGroup"&gt; &lt;/asp:TextBox&gt;
                        &lt;/div&gt;
                        &lt;div class="storesDiv"&gt;
                            &lt;asp:Label ID="LabelStores" CssClass="StoreLabel" Text="Your favourite Mountain Warehouse store:"
                                runat="server"&gt;&lt;/asp:Label&gt;
                            &lt;asp:DropDownList ID="Stores" CssClass="storesDD" runat="server" ToolTip="Stores"
                                EnableViewState="true" AppendDataBoundItems="True" OnSelectedIndexChanged="Stores_SelectedIndexChanged"&gt;
                            &lt;/asp:DropDownList&gt;
                        &lt;/div&gt;
                    &lt;/div&gt;
                    &lt;div class="enterbtn"&gt;
                        &lt;asp:Button ID="emailJoinButton" CssClass="emailJoinButton" runat="server" OnClick="emailJoinButton_Click"
                            Text="ENTER" EnableViewState="False" ValidationGroup="EmailGroup" /&gt;
                    &lt;/div&gt;
                &lt;/div&gt;
                &lt;div id="competitionSurvey" runat="server"&gt;
                    &lt;div class="SCHeaderInfo"&gt;
                        &lt;h2&gt;
                            Thank you! We will notify the lucky winner by email.
                        &lt;/h2&gt;
                        &lt;h3&gt;
                            We'd love to send you tailored special offers - just take a few moments to fill
                            out the following optional details.
                        &lt;/h3&gt;
                    &lt;/div&gt;
                    &lt;div class="SCquestionsDetails"&gt;
                        &lt;p&gt;
                            &lt;b&gt;1. What are you interested in?&lt;/b&gt;&lt;span class="small"&gt; (Select all that apply)&lt;/span&gt;&lt;/p&gt;
                        &lt;asp:CheckBoxList ID="Interests" runat="server" CssClass="interests" Width="400"&gt;
                            &lt;asp:ListItem&gt;Camping&lt;/asp:ListItem&gt;
                            &lt;asp:ListItem&gt;Hiking&lt;/asp:ListItem&gt;
                            &lt;asp:ListItem&gt;Skiing&lt;/asp:ListItem&gt;
                            &lt;asp:ListItem&gt;Travel&lt;/asp:ListItem&gt;
                            &lt;asp:ListItem&gt;Walking&lt;/asp:ListItem&gt;
                            &lt;asp:ListItem&gt;Everything&lt;/asp:ListItem&gt;
                            &lt;asp:ListItem&gt;Mens&lt;/asp:ListItem&gt;
                            &lt;asp:ListItem&gt;Womens&lt;/asp:ListItem&gt;
                            &lt;asp:ListItem&gt;Kids&lt;/asp:ListItem&gt;
                        &lt;/asp:CheckBoxList&gt;
                    &lt;/div&gt;
                &lt;/div&gt;
            &lt;/ContentTemplate&gt;
        &lt;/ajax:UpdatePanel&gt;
    &lt;/div&gt;
&lt;/div&gt;
</code></pre>

<p>================================</p>

<h1>Here is my Code</h1>

<pre><code>protected void Page_Load(object sender, EventArgs e)
            {
                        if (!Page.IsPostBack)
                                    BindAllStores();
            }




  protected void emailJoinButton_Click(object sender, EventArgs e)
            {
                        Session["FavStore"] = Stores.SelectedItem.ToString(); --&gt; this is where i am storing the selected value.

                        if (Page.IsValid)
                        {
                                    if (competitionInfo.Visible == true)
                                    {
                                                LoadSurvey();
                                                competitionInfo.Visible = false;
                                                competitionSurvey.Visible = true;
                                    }
                        }
            }


public void  BindAllStores()
            {
                        Stores.AppendDataBoundItems = true;    
                        Stores.Items.Add(new ListItem("--- Choose one of our stroes --- ", "0"));


                        Stores.DataSource = AllStores;
                        Stores.DataTextField = "DisplayName";
                        Stores.DataValueField = "NAME";
                        Stores.DataBind();
            }
</code></pre>

<p>what i am doing is i am hiding one div when clicked and showing another div with all the survey questions and when submit i need to get the value of previous div which has the dropdownlist.</p>

<p>please help me out as i am finding it very difficult.</p>

<p>thanks all.</p>
