title: How to return multiple table as jsonreult in asp.net MVC?
body: <p>I am getting multiple tables from store procedure result. I want to return this all table as the JsonResult in asp.Net MVC as a ajax response. but I am not getting response in <code>console.log(response);</code>. How to return multiple table as Jsonresult in MVC controller?</p>
  
  <p>My debugger enter into method and getting data from store procedure and returning as a Json but after then in console I am getting error as bellow, </p>
  
  <p><a href="https://i.stack.imgur.com/17ZhF.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/17ZhF.png" alt="enter image description here"></a></p>
  
  <p>In ajax request, I have call <code>GetKYCListForUpdate</code> method as bellow,</p>
  
  <pre><code> $('#KycListTable tbody').on('click', '.btn-edit', function (e) {
          var data = table.row($(this).parents('tr')).data();
  
          if (data.PartyBillId != null) {
              $.ajax({
                  type: "POST",
                  url: "@Url.Action("GetKYCListForUpdate", "KYCRegistration")",
                  data: { id: data.PartyBillId },
                  success: function (response) {
                      debugger
                      console.log(response);
                      var result = response.aaData;
                      if (result != null) {
                          $.each(result, function (i, item) {
                              console.log(item)
                          });
                      }
                  }
              });
          }
      });
  </code></pre>
  
  <p>in asp.net MVC controller method as bellow,</p>
  
  <pre><code>  public JsonResult GetKYCListForUpdate(int id)
      {
          var AuthId = NC.ToInt(((Variables.scUserDetail)Session["UserDetail"]).AuthId);
          SqlConnection objsql = default(SqlConnection);
          objsql = new SqlConnection(Connect.GetConnStr(1));
  
          DataSet dsData = new DataSet();
          SqlCommand objSelectCmd = new SqlCommand();
          try
          {
              //objsql.ConnectionString = objsql;
              objsql.Open();
              objSelectCmd.CommandType = CommandType.StoredProcedure;
              objSelectCmd.Connection = objsql;
              objSelectCmd.CommandText = "Sp_M35_01_GetKycListToEdit";
              objSelectCmd.Parameters.AddWithValue("@BillPartyId", id);
              objSelectCmd.Parameters.AddWithValue("@AuthId", AuthId);
  
              SqlDataAdapter objDataAdapter = new SqlDataAdapter();
              objDataAdapter = new SqlDataAdapter(objSelectCmd);
              objDataAdapter.Fill(dsData);
  
  
              for (int i = 0; i &lt; dsData.Tables.Count; i++)
              {
                  if (dsData.Tables[i].Rows.Count &gt; 0)
                  {
  
                      result.Add(GetTableRows(dsData.Tables[i]));
                  }
              }
  
     return Json(new { aaData = result }, JsonRequestBehavior.AllowGet);
  }
  
  public List&lt;Dictionary&lt;string, object&gt;&gt; GetTableRows(DataTable dtData)
      {
          List&lt;Dictionary&lt;string, object&gt;&gt;
          lstRows = new List&lt;Dictionary&lt;string, object&gt;&gt;();
          Dictionary&lt;string, object&gt; dictRow = null;
  
          foreach (DataRow dr in dtData.Rows)
          {
              dictRow = new Dictionary&lt;string, object&gt;();
              foreach (DataColumn col in dtData.Columns)
              {
                  dictRow.Add(col.ColumnName, dr[col]);
              }
              lstRows.Add(dictRow);
          }
          return lstRows;
      }
  </code></pre>