title: ASP:DropDownList in ItemTemplate: Why is SelectedValue attribute allowed?
body: <p>This piece of code</p>
  
  <pre><code>&lt;asp:DropDownList runat="server" ID="testdropdown" SelectedValue="2"&gt;
      &lt;asp:ListItem Text="1" Value="1"&gt;&lt;/asp:ListItem&gt;
      &lt;asp:ListItem Text="2" Value="2"&gt;&lt;/asp:ListItem&gt;
      &lt;asp:ListItem Text="3" Value="3"&gt;&lt;/asp:ListItem&gt;
  &lt;/asp:DropDownList&gt;
  </code></pre>
  
  <p>yields this error:</p>
  
  <blockquote>
    <p>The 'SelectedValue' property cannot be
    set declaratively.</p>
  </blockquote>
  
  <p>Yet, this is a legal and commonly used edit template for databound GridViews.  The <code>SelectedValue</code> attribute certainly appears to be declaratively set here.</p>
  
  <pre><code>&lt;EditItemTemplate&gt;
      &lt;asp:DropDownList runat="server" 
          ID="GenreDropDownList"
          DataSourceID="GenreDataSource" 
          DataValueField="GenreId"
          DataTextField="Name"
          SelectedValue='&lt;%# Bind("Genre.GenreId") %&gt;'&gt;
      &lt;/asp:DropDownList&gt;
  &lt;/EditItemTemplate&gt;
  </code></pre>
  
  <p>The question is:  what is the difference between the cases when you are allowed to set it declaratively and those in which you are not?  The error message implies that it's never allowed.</p>