title: Return Json of SelectList in asp.net mvc?
body: <p>I'd apreciate if someone could advise on the following:</p>
  
  <p>I have my SelectList in the controller:</p>
  
  <pre><code> SelectList sl = new SelectList(_unitOfWork.TraumaRepo.GetByType(type).ToList(), "Code", "Name");
  </code></pre>
  
  <p>Normally my Json returns simple strings:</p>
  
  <pre><code>  return Json(new[]{
                          new { value = "1", text = "item 1" },
                          new { value = "2", text = "item 2" }}, 
                          JsonRequestBehavior.AllowGet);
  </code></pre>
  
  <p>How can iterate through this SelectList to return its data value and data text fields as JsonResult? How to include foreach or linq into Json()?</p>
  
  <p>In my View I append it to my DropDownList:</p>
  
  <pre><code>    $.each(data, function (value, i) {
  
                      ddl.append(
                              $('&lt;option/&gt;', {
                                  value: i.value,
                                  html: i.text
                              }));
  
                  });
  </code></pre>