title: Asp.net mvc select list
body: <p>I need to create a select list, preserving the state, which is not part of the model passed to the view. I suppose I should be using a ViewBag to pass a List to the View ? Any advise on implementation and how to preserve the state of the select list (how do I pass the selected value back to action and to the view again (possible ways of doing this) ?</p>
  
  <p>The Action as of now:</p>
  
  <pre><code>public ActionResult Images(string x, string y)
  {
  //some code 
  
  ContentPage cp = this.ContentPage;
  
  return View(cp);
  } 
  
  //Post to action with same name:
  [HttpPost]
  public ActionResult Images(string someParameter)
   {
  
      ContentPage cp = this.ContentPage;
  
      return View(cp);
   }
  </code></pre>
  
  <p>The view as of now :</p>
  
  <pre><code>@model ContentPage
  @{
  ViewBag.Title = "Images";
  CmsBaseController controller = (this.ViewContext.Controller as CmsBaseController);
  }
  @using (Html.BeginForm())
  { 
  &lt;div&gt;
  
  //This should go to List&lt;SelectListItem&gt; as I understand
  &lt;select name="perpage" id="perpage" onchange='submit();'&gt;
             &lt;option value="1"&gt;1&lt;/option&gt;
             &lt;option value="2"&gt;2&lt;/option&gt;
             &lt;option value="3"&gt;3&lt;/option&gt;
  
  &lt;/select&gt;
  &lt;/div&gt;
  }
  </code></pre>
  
  <p>Thank you!!!</p>