title: Keeping selected item from dropdown box after page refresh
body: <p>I have a dropdown box with a list of times for the user to choose from. My problem is that after the user picks their choice and then hits the submit button, the page is refreshed and then the dropdown box is set to default again - how can i have the users choice stay in the dropdown box even after a page reload? I am not sure what part of my code is needed best my Get and Post are long - but if there is a general example that would help.</p>
  
  <p>CODE FROM CONTROLLER:</p>
  
  <p>Here is one of my lists i load into the dropdown box: </p>
  
  <pre><code>IQueryable&lt;User&gt; users = _userRepository.FindAllForOffice(_currentUser.OfficeId);
              userViewModel.Users = users.ToSelectList("UserId", "FullName",
                                                                     userViewModel.UserId.ToString());
  
              foreach (SelectListItem view in userViewModel.Users)
              {
                  if (!viewData.ContainsKey(view.Text))
                      viewData.Add(view.Text, view.Value + "|user");
              }
  </code></pre>
  
  <p>This is adding to the actual dropdown: </p>
  
  <pre><code>userViewModel.ViewData = viewData.ToSelectList("Value", "Key",
                                                                           userViewModel.Value);
              return View("UserSummary", userViewModel);
  </code></pre>
  
  <p>ON MY ASPX.CS page i have the following: </p>
  
  <p>Page_Load</p>
  
  <pre><code>string viewType = null;
  if(!String.IsNullOrEmpty(Request.QueryString["viewType"]))
          {
              viewType = Request.QueryString["viewType"];
          }
  
  
  if(!IsPostBack)
          { if (viewType == "user")
                  {
                      viewParams.Add("ViewName", "User Report");
                      var reportDataSource =
                          _userService.GetUsersReportData(beginDate, endDate, id);
                      reportViewer.Initialize("UserIndividual.rdlc",
                                              new List&lt;ReportDataSource&gt; {reportDataSource}, viewParams);
                  }
  </code></pre>
  
  <p>I didn't add all the initialization for all the elements - didn't think it is really needed for this situation </p>
  
  <p>Thanks</p>