title: How to loop through Json object to bind data to dropdownlist
body: <p>I am trying to loop through a Json object to populate data in dropdown but getting undefined.I don't know where i am doing wrong.Below is the code:</p>
  
  <p>My Javascript code:</p>
  
  <pre><code>function CIOAnalyzeByDropDown() {
          $.ajax({
              type: "POST",
              contentType: "application/json; charset=utf-8",
              //url: '../../CIODashboard.svc/GetAnalyzedDropDownDetails',
              url: '../../CIODashboard/GetAnalyzedDropDownDetails',
              dataType: "json",
              processData: false,
              success: function (data) {
                  debugger;
                  //var s = JSON.parse(data.d);
                  var s = JSON.stringify(data);
                  debugger;
                  for (x in s) {
  
                      if (s[x].dropDowns == "Created_Date") {
                          $("#drop1").append("&lt;option value=" + s[x].dropDowns + "  selected &gt;" + s[x].dropDowns + "&lt;/option&gt;");
                      }
                      else {
                          $("#drop1").append("&lt;option value=" + s[x].dropDowns + "&gt;" + s[x].dropDowns + "&lt;/option&gt;");
                      }
                  }
  
  
  
  
              },
              error: function (result) {
                  alert(result + "error occured while fetching the ProjectsSummary values");
              }
          });
      }
  </code></pre>
  
  <p>My Contoller code :</p>
  
  <pre><code> public string GetAnalyzedDropDownDetails()
      {
          string jsonString = string.Empty;
          List&lt;projectDropDowns&gt; itemList = new List&lt;projectDropDowns&gt;();
  
          using (SqlConnection con = new SqlConnection(strConnection))
          {
              con.Open();
              SqlCommand cmd = con.CreateCommand();
              cmd.CommandType = CommandType.StoredProcedure;
              cmd.CommandText = "usp_AnalyzeByDropdown";
              cmd.CommandTimeout = 60;
  
              SqlDataAdapter da = new SqlDataAdapter(cmd);
              DataTable dtresult = new DataTable();
              da.Fill(dtresult);
  
              if (dtresult.Rows.Count &gt; 0)
              {
                  for (int i = 0; i &lt; dtresult.Rows.Count; i++)
                  {
                      projectDropDowns info = new projectDropDowns();
                      info.dropDowns = "" + dtresult.Rows[i]["COLUMN_NAME"];
                      itemList.Add(info);
                      jsonString = SerializeJSon&lt;List&lt;projectDropDowns&gt;&gt;(itemList);
                      //return jsonString;
                  }
              }
              con.Close();
          }
          return jsonString;
      }
  </code></pre>
  
  <p>Serialize Json method :</p>
  
  <pre><code>public string SerializeJSon&lt;T&gt;(T t)
      {
          MemoryStream stream = new MemoryStream();
          DataContractJsonSerializer ds = new DataContractJsonSerializer(typeof(T));
          ds.WriteObject(stream, t);
          string jsonString = Encoding.UTF8.GetString(stream.ToArray());
          stream.Close();
          return jsonString;
      }
  </code></pre>
  
  <p>It is returning an array object containing 3 values in it but in my dropdown it is showing Undefined.
  Any help would be much appreciated.</p>