title: Html.DropDownList razor
body: <p>I'm new to MVC and C# and having hard time with a dropdown list.  </p>
  
  <p>What I'm trying to accomplish is to initialize my page with an object that keeps the settings.<br>
  (I read settings from XML file).</p>
  
  <p>Here's what I have  </p>
  
  <pre><code>public class StoreSettings  
  {  
      public String BackSrs2Path { get; set; }  
      public int NoLines { get; set; }  
      public String Requesturl { get; set; }  
  }  
  
  public class Store  
  {  
      public String StoreId { get; set; }  
      public String Address { get; set; }  
      public StoreSettings StoreSettings { get; set; }  
  }  
  </code></pre>
  
  <p>and the Model for my view page is a list of Store  </p>
  
  <pre><code>@model System.Collections.Generic.List&lt;Control2.Models.Store&gt;  
  @{     
  List&lt;SelectListItem&gt; selectList = new List&lt;SelectListItem&gt;();  
  foreach (var Store in Model)  
  {  
  SelectListItem i = new SelectListItem();  
  i.Text = Store.StoreId;  
  i.Value = Store.StoreId;  
  selectList.Add(i);  
  }  
   }  
   @using (Html.BeginForm())  
  {  
   SelectList list = new SelectList(selectList, "Value", "Text");  
   @Html.DropDownList("ddl", list, "select store", new { onchange = "this.form.submit();" });  
    }  
    } 
  </code></pre>
  
  <p>By reading examples here managed to populate the dropdownlist from my model and postsback<br>
  but now i need to get only the selected object from the list and apply his seetings to the page to   display it etc a message "you ve selected Store"+Storeid(the slected from dropdown)   </p>
  
  <p>Also this code is written in my cshtml page which isn't the best but couldn't figure how should I do it with ViewModel and dropdown list </p>