title: Set DropDownList selected value in aspx page within a foreach
body: <p>I am trying to set the selected value of a <code>DropDownList</code> in an aspx page within a foreach loop. I want the selected value to be set based on a property from the current object within the foreach. </p>
  
  <p>The code is as below.</p>
  
  <pre><code>&lt;% foreach (ColorScheme AColorScheme in ColourSchemeList)
         { %&gt;
      &lt;div class="form-horizontal content-row" id="colorSchemeForm" &gt;
          &lt;div class="form-group"&gt;
              &lt;label class="alert-info col-xs-6 col-xs-offset-1"&gt;
                  Terminal:&amp;nbsp;
              &lt;%: AColorScheme.TerminalName %&gt;
              &lt;/label&gt;&amp;nbsp;
              &lt;asp:LinqDataSource runat="server" ID="Colors" ContextTypeName="ColorSchemeParts.ColorSchemeHolder" TableName="AvailableColorSchemes"&gt;&lt;/asp:LinqDataSource&gt;
              &lt;asp:DropDownList runat="server" SelectedValue="'&lt;%: AColorScheme.ThemeName; %&gt;'" ID="tbTerminalColorScheme" DataSourceID="Colors"&gt;&lt;/asp:DropDownList&gt;
          &lt;/div&gt;
      &lt;/div&gt;
      &lt;% } %&gt;
  </code></pre>
  
  <p>I am so far unable to access the property <code>AColorScheme.ThemeName</code> (I have tried different inline expression tags but so far without any luck) and I am now wondering if it is even possible.</p>