title: How to set a asp:DropDownList SelectedValue to a Session Variable?
body: <p>There are several articles describing how to do this is code behind however:</p>
  
  <h2>Is it possible to set the value of a dropdownlist to a session variable on the aspx page?</h2>
  
  <p>I am using SqlDataSource to populate the dropdownlist so do not wish to add code behind if it can be avoided.</p>
  
  <pre><code>&lt;asp:DropDownList ID="ddl" runat="Server" DataSourceID="sqlDS" DataValueField="ID" DataTextField="TEXT" AppendDataBoundItems="true"&gt;
    &lt;asp:ListItem Text="" Value="" Selected="True" /&gt;
  &lt;/asp:DropDownList&gt;
  
  &lt;asp:SqlDataSource ID="sqlDS" runat="Server" SelectCommand="spDS" SelectCommandType="StoredProcedure" /&gt;
  </code></pre>
  
  <p>Set <strong>Session("ID")</strong> as selected value on load?</p>
  
  <hr>
  
  <p>The dropdown list is already populated from the sqldatasource. I just want to set the initial value on page load.</p>