title: How to add ListItem to DropDownList from code and get the selected value
body: <p>I succeeded adding List-items to my DropDownList from my database, but after I ran my application and selected a value from the DropDownList, I checked my break point at code and I saw that the selected value is wrong. It always selects the first value.</p>
  
  <p>My code is:</p>
  
  <pre><code>UserBLL uBLL = new UserBLL();
  List&lt;Item&gt; list = uBLL.GetAllItemsCategory();
  foreach (Item item in list)
  {
      int var = 1;
      ListItem lItem = new ListItem(item.name, var.ToString());
      modelsList.Add(lItem);
      var++;
  }
  
  DropDownList2.DataSource = modelsList;  
  DropDownList2.DataBind();
  </code></pre>
  
  <p>How can I fix it so that when the following is executed I'll get the right selection and not just the first item?</p>
  
  <pre><code>order.nameItem = DropDownList2.SelectedValue;
  </code></pre>