Click here to Skip to main content
15,885,216 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,

I have a dataset with has multiple datatable ,I want to bind each datatable to ampie charts ,
for this i need to convert each datatable to json object and then bind my charts.
for single datatable my code is as follow

C#
[WebMethod]
   public static UserDetails[] BindDatatable(long pvid, long deptid, long locid, long blgid, string article)
   {
       DataTable dt = new DataTable();
       List<UserDetails> details = new List<UserDetails>();
       //string connectionstring = "Data Source=DCS_SERVER;Initial Catalog=DSIM_CLOUD;User ID=sa;Password=sa123;Timeout=200";

       string connectionstring = ConfigurationManager.ConnectionStrings[System.Web.HttpContext.Current.Session["ConnectionStringNuggettsCloud"].ToString()].ConnectionString;
       SqlConnection con = new SqlConnection(connectionstring);
       con.Open();
       SqlCommand comm = new SqlCommand("usp_ReportException", con);
       comm.CommandType = CommandType.StoredProcedure;
       comm.Parameters.Add("@pvid", SqlDbType.BigInt).Value = pvid;

       SqlDataAdapter da = new SqlDataAdapter(comm);
       da.Fill(dt);
       foreach (DataRow dtrow in dt.Rows)
       {
           UserDetails user = new UserDetails();
           user.Article_desc = dtrow["Article_desc"].ToString();
           user.model = dtrow["model"].ToString();

           details.Add(user);
       }

       con.Close();

       // }
       return details.ToArray();

   }
   public class UserDetails
   {
       public string Article_desc { get; set; }
       public string model { get; set; }


   }


<script type="text/javascript">
     $(document).ready(function () {
         //  debugger
         $.ajax({
             type: "POST",
             contentType: "application/json; charset=utf-8",
             url: "ExceptionReport.aspx/BindDatatable",
             data: "{pvid:" + $("#hndPVID")[0].value + ",deptid:" + $("#hndDeptid")[0].value + ",locid:" + $("#hndLocid")[0].value + ",blgid:" + $("#hndBlgid")[0].value + ",article:" + $("#hndArticle")[0].value + "}",
             dataType: "json",
             success: function (data) {
                 // debugger
                


             },
             error: function (result) {
                 alert("Error");
             }
         });


      

     });
    </script>


This is way i am binding charts with single datatable ,with if there is dataset with multiple datatable then how is it possible please help.

JavaScript
SqlDataAdapter da = new SqlDataAdapter(comm);
      da.Fill(ds);


then how will i convert dataset with multiple datatable to json ??
Posted
Updated 19-Aug-14 0:33am
v2

1 solution

 
Share this answer
 
Comments
Gihan Liyanage 15-Sep-14 6:17am    
Did you got a solution from my support, I can see you have not accepted any answer.If you are ok with this answer plz accept it. Then any user having same problem can identified it has solved the problem..

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900