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
[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 = 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.
SqlDataAdapter da = new SqlDataAdapter(comm);
da.Fill(ds);
then how will i convert dataset with multiple datatable to json ??