Unable to retrieve DDL SelectedValue bound in ASPX after Page Load
<p>I have the following markup / code block in the ASPX file.
The binding of the ddl is triggered after Page_Load event which is in the code behind file.
This results me not able to get the selected value of the dropdownlist if I were to use such flow.</p>

<p>However for some purpose I require it to work this way.
Any idea how I could get the dropdownlist selected value when a post back is being triggered (click of the button)?</p>

<pre><code>Page URL: page.aspx?para1=0&amp;para2=value
</code></pre>

<p>ASPX PAGE</p>

<pre><code>&lt;% 
    if (Convert.ToInt32(Request.QueryString["para1"]) == 0)
    {
        ddl.DataValueField = "value"; 
        ddl.DataTextField = "text"; 
        ddl.DataSource = ds; //ds is valid, exact code not shown
        ddl.DataBind(); 
    } else {
        //write in this area
        Response.Write("Not 0");
    }
%&gt; 
&lt;form runat="server" id="user_form" class="form-horizontal"&gt; 
&lt;asp:ToolkitScriptManager ID="ToolkitScriptManager1" runat="server"&gt; 
&lt;/asp:ToolkitScriptManager&gt; 
&lt;asp:UpdatePanel ID="updPanel" runat="server"&gt; 
    &lt;ContentTemplate&gt; 
        &lt;asp:DropDownList runat="server" ID="ddl"&gt; 
        &lt;/asp:DropDownList&gt; 
        &lt;%-- this button will call btnSave_Click to get the ddl's value--%&gt;
        &lt;asp:Button runat="server" ID="btn" Text="Button" OnClick="btn_Click" /&gt;
    &lt;/ContentTemplate&gt; 
&lt;/asp:UpdatePanel&gt; 
&lt;/form&gt; 
</code></pre>

<p>CODE BEHIND</p>

<pre><code>protected void Page_Load(object sender, EventArgs e) 
{ 
    if (!IsPostBack) 
    { 
        //do my stuff 
    } 
} 

protected void btn_Click(object sender, EventArgs e) 
{ 
    int intValue = Convert.ToInt32(ddl.SelectedValue); 
    //do my stuff 
} 
</code></pre>

<p>The ASPX Page code block will run after Page_Load / page's lifecycle, then will determine what to do base on the url parameters.
Thanks in advance!</p>
