<p>I'm handling the <code>onSelectIndexChanged</code> event. An event is raised when the DropDownList selection changes. the problem is that the DropDownList still returns the old values for <code>SelectedValue</code> and <code>SelectedIndex</code>. What am I doing wrong?</p>

<p>Here is the DropDownList definition from the aspx file:</p>

<pre><code>&lt;div style="margin: 0px; padding: 0px 1em 0px 0px;"&gt;
    &lt;span style="margin: 0px; padding: 0px; vertical-align: top;"&gt;Route:&lt;/span&gt;
    &lt;asp:DropDownList id="Select1" runat="server" onselectedindexchanged="index_changed" AutoPostBack="true"&gt;
    &lt;/asp:DropDownList&gt;
    &lt;asp:Literal ID="Literal1" runat="server"&gt;&lt;/asp:Literal&gt;
&lt;/div&gt;
</code></pre>

<p>Here is the DropDownList <code>OnSelectedIndexChanged</code> event handler:</p>

<pre><code>protected void index_changed(object sender, EventArgs e)
{
    decimal d = Convert.ToDecimal( Select1.SelectedValue );
    Literal1.Text = d.ToString();
}
</code></pre>

[{'answer_id': 75306, 'author': 'Mitchel Sellers', 'author_id': 13279, 'author_profile': 'https://Stackoverflow.com/users/13279', 'pm_score': 5, 'selected': True, 'text': '<p>Do you have any code in page load that is by chance re-defaulting the value to the first value?</p>\n\n<p>When the page reloads do you see the new value?</p>\n'}, {'answer_id': 75383, 'author': 'Donn Felker', 'author_id': 5210, 'author_profile': 'https://Stackoverflow.com/users/5210', 'pm_score': 0, 'selected': False, 'text': '<p>Is it possible that you have items copied throughout your datasource for the drop down list? </p>\n'}, {'answer_id': 75389, 'author': 'Community', 'author_id': -1, 'author_profile': 'https://Stackoverflow.com/users/-1', 'pm_score': 2, 'selected': False, 'text': '<p>add this:\nif page.isnotpostback {</p>\n\n<p>}\naround your code to bind the dropdownlist. </p>\n'}, {'answer_id': 75437, 'author': 'axk', 'author_id': 578, 'author_profile': 'https://Stackoverflow.com/users/578', 'pm_score': 2, 'selected': False, 'text': '<p>This may seem obvious, but anyway.\nDo you initialize this dropdown with an initial value in some other event handler like OnLoad ?\nIf so you should check if that event is risen by a postback or by the first load. So you should have something like</p>\n\n<pre><code>if(!IsPostback) d.SelectedValue = "Default"\n</code></pre>\n'}, {'answer_id': 75827, 'author': 'Jason Stevenson', 'author_id': 13368, 'author_profile': 'https://Stackoverflow.com/users/13368', 'pm_score': 2, 'selected': False, 'text': '<p>If you are using AJAX you may also be doing a callback, not a full postback.  In that case you may want to use this in your page load method:</p>\n\n<pre><code>        if (!IsCallback &amp;&amp; !IsPostBack)\n        {\n            // Do your page setup here\n        }\n</code></pre>\n'}]
['https://Stackoverflow.com/questions/75282', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/4491/']