title: Set the selected value for a DropDownList using SelectListItem
body: <p>Although this question has been asked for several times, still I am  struggling to find a solution for a problem </p>
  
  <p>I have a drop down and i want to bind the selected value when retrieving data.
  here is my controller</p>
  
  <pre><code>studentList = db.Students
                      .Select(x =&gt; new SelectListItem
                      {
                          Value = x.StudentId.ToString(),
                          Text = x.StudentNo + " - " + x.StudentNameEn
                      }).ToList();
                  ViewData["studentList"] = studentList;
  </code></pre>
  
  <p>here is my view</p>
  
  <pre><code> @Html.DropDownList("StudentNo", ViewData["studentList"] as List&lt;SelectListItem&gt;, "---Please Select---", new { @class = "form-control selectpicker", id = "studentIdDrp" })
  </code></pre>
  
  <p><strong>What I have tried</strong></p>
  
  <ol>
  <li><p>I tried to bind the value using jquery</p>
  
  <pre><code>$("#studentIdDrp").val('@Model.AppointmentViewModel.FK_StudentId');
  </code></pre></li>
  <li><p>I tried from the controller to set the selected attribute true</p>
  
  <pre><code>foreach(var item in studentList)
              {
                  if (item.Value == appoinmnetRec.FK_StudentId.ToString())
                  {
                      item.Selected = true;
                  }
              }
  </code></pre></li>
  </ol>
  
  <p>None of the above methods working. Please help, thanks in advance</p>