title: ASP.NET C# Set OnSelectedIndexChanged from Code Behind
body: <p>Im trying to set the SelectedIndexChanged from the code behind of a Web Forms application. I have a variable amount of dropdowns being added onto the page from the database and need a method to trigger each time one of the dropdowns change. </p>
  
  <p>Im currently trying:</p>
  
  <pre><code>ddlProductCause.SelectedIndexChanged += new EventHandler(ddlProductCause_Changed);
  ddlProductCause.ID = "ddlProductCause_" + row["item_id"].ToString();
  ddlProductCause.AutoPostBack = true;
  </code></pre>
  
  <p>and...</p>
  
  <pre><code>public void ddlProductCause_Changed(object sender, CommandEventArgs e)
      {
          // do stuff
      }
  </code></pre>
  
  <p>But I have no luck.</p>
  
  <p>Any ideas?</p>