title: Issue To Select/Show DropDown Selected Value At Edit() In Asp.net MVC 3
body: <p>I Using Two Table User And Location In User Table I having LocationId And When I'm going to edit The User Form Then I need User With There Exact Location In Drop Down.but i didn't get that this is my code Of Controller:-</p>
  
  <pre><code>LogisticsEntities db = new LogisticsEntities();
  
  RegisterModel Reg = new RegisterModel();
  
  var tempUser = (from c in db.Users select new RegisterModel { _UserId = c.UserID, UserName = c.Name, Code = c.Code, Email = c.Email, Phone = c.Phone, JobRole = c.JobRole, StartDate = c.StartDate, EndDate = c.EndDate, LocationId = c.Location }).SingleOrDefault(x =&gt; x._UserId == id);
  
  var varLocation = from Ls in db.Locations select Ls;
  
  ViewData["LocationId"] = new SelectList(varLocation.ToList(), "LocationID", "Location1", "2");
  
  if (tempUser != null)
  
  return View(tempUser);
  
  else
  
  return View();
  </code></pre>
  
  <p>And In My View I Have code: -</p>
  
  <pre><code>@Html.DropDownList("LocationID", (SelectList)ViewData["LocationId"])
  </code></pre>
  
  <p>Thanx In Advance..</p>