EnableViewState not working in DropDownList
<p>The default.aspx page has a <code>DropDownList</code> which is populated in the code behind only when it is not a <code>postback</code>. When a value is selected a method is called which fills a <code>Literal</code> with the selected value. It works as expected. The problem is when I set the page to not <code>EnableViewState</code> enabling it in the <code>DropDownList</code> control only. In this case when posted back the <code>DropDownList</code> loses its items. I have setup a new Web project just to test this. There is no master page to make it simpler. </p>

<p>Default.aspx:</p>

<pre><code>&lt;%@ Page Title="Home Page" Language="C#" AutoEventWireup="true"
    CodeBehind="Default.aspx.cs" Inherits="WebApplication4._Default" 
    EnableViewState="false" %&gt;

&lt;asp:DropDownList ID="DDL" runat="server" 
    OnSelectedIndexChanged="DDL_OSIC" 
    AutoPostBack="true" 
    EnableViewState="true"&gt;
&lt;/asp:DropDownList&gt;

&lt;asp:Literal ID="Literal1" runat="server"&gt;&lt;/asp:Literal&gt;
</code></pre>

<p>Default.aspx.cs:</p>

<pre><code>protected void Page_Load(object sender, EventArgs e)
{
    if (!IsPostBack)
    {
        DDL.Items.Add("red");
        DDL.Items.Add("green");
        DDL.Items.Add("blue");
    }
}
protected void DDL_OSIC(object sender, EventArgs e)
{
    Literal1.Text = DDL.SelectedValue;
}
</code></pre>

<p>Why isn't EnableViewState working?</p>
