title: C# DropDownList default values
body: <p>I am working with a ascx.cs backend page to try and use four different filters "dropdowns" when selecting a report with parameters. Currently my filers and dropdown lists are working and the parameters are passing and returning back the correct report.</p>
  
  <p>However my values for the drop down lists are generated from the most recent values in a database table, namely month and year. </p>
  
  <p>(eg. year - 2014)
  (eg. month - March)</p>
  
  <p>My tables in the database only add each month as they happen so currently (today= 2014-06-10)
  therefore to date i have the first few months of 2014.</p>
  
  <p>So to my problem. I am trying to display the most recent values as default. For example in the "year" dropdown that would be 2014 and for the "month" drop down it would be last month.</p>
  
  <p>I also must note that each of my four drop down filters has an autopostback Onselectedchange</p>
  
  <p>example (year)</p>
  
  <pre><code>dropdown_year.Items.Clear();
          dropdown_year.Items.Add(new ListItem("Select a year...", "0"));
  </code></pre>
  
  <p>this is within the backend </p>
  
  <p>in the front end things look like this</p>
  
  <pre><code>&lt;div class="field"&gt;
                          &lt;div class="field-left"&gt;
                              &lt;label for="dropdown_year" runat="server"&gt;Year&lt;/label&gt;
                          &lt;/div&gt;
                          &lt;div class="field-right"&gt;
                              &lt;asp:DropDownList runat="server" ID="dropdown_year" OnSelectedIndexChanged="dropdown_year_SelectedIndexChanged" AutoPostBack="true"&gt;&lt;/asp:DropDownList&gt;
                              &lt;span id="dropdown_year_error" class="error-message" runat="server"&gt;&lt;/span&gt;
                          &lt;/div&gt;
                      &lt;/div&gt;
  </code></pre>
  
  <p>can anyone suggest how i might be able to get the most recent values?</p>