title: SelectedValue of DropDownList in Repeater
body: <p>How do I set the selected item of a dropDownList inside a repeater?</p>
  
  <p>The repeater is bound to the repeaterData DataTable and the dropDownList is bound to dropDownList DataTable in the code behind. I need to set the SelectedValue property of the DropDownList to the value of a field from the repeaterData table.</p>
  
  <p>This is what I've tried:</p>
  
  <pre><code>&lt;asp:Repeater runat="server" ID="myRepeater&gt;
  &lt;ItemTemplate&gt;
      &lt;asp:DropDownList runat="server" CssClass="fullSelect" ID="degree_dropdown"
              AppendDataBoundItems="true" 
              selectedValue='&lt;%#DataBinder.Eval(Container.DataItem,"degreeCode")%&gt;'&gt;
                    &lt;asp:ListItem Text="Select Degree" /&gt;
       &lt;/asp:DropDownList&gt;
  &lt;/ItemTemplate&gt;
  &lt;/asp:Repeater&gt;
  </code></pre>
  
  <p>Code to populate repeater:</p>
  
  <pre><code>myRepeater.DataSource = myRepeaterData; //myRepeaterData is a datatable
  myRepeater.DataBind();
  </code></pre>
  
  <p>Code to populate dropdownlist:</p>
  
  <pre><code>protected void educationPopup_repeater_ItemDataBound(object sender, RepeaterItemEventArgs e)
          {
              DropDownList degree_dropdown = e.Item.FindControl("degree_dropdown") as DropDownList;
              if (degree_dropdown != null)
              {
                  degree_dropdown.DataSource = degrees; //a datatable
                  degree_dropdown.DataTextField = "degree";
                  degree_dropdown.DataValueField = "code";
                  degree_dropdown.DataBind();
              }
  }
  </code></pre>