title: Dropdownlist error when dynamically generated?
body: <p>I am creating a dropdownlist called "ddlYears" dynamically like below code:</p>
  
  <pre><code>private void CreateDynamicDDL()  
  {      
      ddlYears.Items.Clear();
      ddlYears.Items.Add(new ListItem("Year","0")); 
      for (int k = 0; k &lt; 4; k++)  
      {  
          int time = int.Parse(DateTime.Now.Year.ToString());
          ddlYears.Items.Add(new ListItem((time-k).ToString(),(k+1).ToString()));    
      }
  }  
  </code></pre>
  
  <p>and I have ddl selectedindexchanged event as below:</p>
  
  <pre><code>protected void ddlYears_SelectedIndexChanged(object sender, EventArgs e)     
  {    
      Response.Write(ddlYears.SelectedValue.ToString());
      Response.End();
  } 
  </code></pre>
  
  <p>In the above code I am trying to write the selected value. But it's working fine, if select the second item which is "2010" (I mean returning selected value as 1) and so on, but if I select first item which is "Year" it's not firing that <code>ddlYears_SelectedIndexChanged</code> event. Please somebody help me</p>
  
  <p>Thanks</p>