title: Not able to set SelectedValue for DropDownList
body: <p>This is a followup from <a href="https://stackoverflow.com/questions/1432790/populating-dropdownlist-inside-repeater-not-working">Populating DropDownList inside Repeater not working</a>.</p>
  
  <p>I'm adding a dropdownlist inside a repeater. Now I need to set the selected value, but that easier said than done...</p>
  
  <p>Here is my code:</p>
  
  <pre><code>    protected void criteriaScore_ItemDataBound(object sender, RepeaterItemEventArgs e)
      {
  
          // This event is raised for the header, the footer, separators, and items.
          // Execute the following logic for Items and Alternating Items.
          if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)
          {
  
              DropDownList ddl = (DropDownList)e.Item.FindControl("ddlRating");
              DataRowView drw = (DataRowView)e.Item.DataItem;
  
              for (int i = 1; i &lt; 6; i++)
              {
                  ddl.Items.Add(new ListItem(i.ToString(), i.ToString()));
              }
              ddl.DataBind(); // &lt;- Not sure if this is needed here.
              ddl.SelectedValue = drw.Row["lvl"].ToString();
          }
      }
  </code></pre>
  
  <p>drw.Row["lvl"].ToString() is a value from 1 -5.</p>
  
  <p>I've tried setting SelectedValue and SelectedIndex.</p>
  
  <p>I also tried</p>
  
  <pre><code>ddl.SelectedValue = Convert.ToString(ddl.Items.FindByText(drw.Row["lvl"].ToString()).Value) ;
  </code></pre>
  
  <p>I'm running out of ideas.</p>