title: How to set Dropdownlist selected value in mvc3
body: <p>I have a dropdownlist which is binding with TempData.when it is coming first time it is showing all values.After selecting a particular value that value is saving in the database correctly.But the selected value is not showing.I am giving my code below.</p>
  
  <p>For retrieving I have written in index action  controller </p>
  
  <pre><code>TempData["Clients"] = (IEnumerable&lt;SelectListItem&gt;)ClientService.GetALLClientsName().Select(C=&gt;new SelectListItem { Value=C.CLIENT_ID.ToString(),Text=C.CLIENT_NAME});
  </code></pre>
  
  <p>when retrieving after editing I can not get the selected value.I have written in razor like this below</p>
  
  <pre><code>@if (TempData["SelectedClientName"] != null &amp;&amp; TempData["SelectedClientId"] != null)
                         {
                             foreach (SelectListItem sli in lstClients)
                             {
                                 if (sli.Value.Equals(TempData["SelectedClientId"].ToString()))
                                 {
                                     sli.Text = TempData["SelectedClientName"].ToString();
                                     sli.Value = TempData["SelectedClientId"].ToString();
                                     sli.Selected = true;
                                     break;    
  
                                 }
                             }
  
                         }
  
                        @Html.DropDownList("drpClientName", lstClients, "--Select--")
  </code></pre>
  
  <p>I have converted  TempData["Clients"] in lstClients.Please help me.</p>