Harish Batchu

Harish Batchu

  • 1.9k
  • 247
  • 49.2k

I have question regarding to load chart on page load?

Nov 1 2018 3:21 AM
 
I read the data from database and return data fromat is json. using json object to preapre the chart data dynamically on page load can any one give me the solution for that.
 
sample code:
protected void Page_Load(object sender, EventArgs e)
{
if (!Page.IsPostBack) {
GetIncome();
}
}
public string GetIncome()
{
string useruniq = "xxxxx";
con = getcon.GetConnection();
cmd = new SqlCommand("xxxx", con);
cmd.CommandType = CommandType.StoredProcedure;
cmd.Parameters.Add("@Uuniq", SqlDbType.VarChar).Value = useruniq;
SqlDataAdapter sda = new SqlDataAdapter(cmd);
DataTable dt = new DataTable();
sda.Fill(dt);
System.Web.Script.Serialization.JavaScriptSerializer serializer = new System.Web.Script.Serialization.JavaScriptSerializer();
List<Dictionary<string, object>> rows = new List<Dictionary<string, object>>();
Dictionary<string, object> row;
foreach (DataRow dr in dt.Rows)
{
row = new Dictionary<string, object>();
foreach (DataColumn col in dt.Columns)
{
row.Add(col.ColumnName, dr[col]);
row.Add(col.ColumnName, dr[col]);
}
rows.Add(row);
}
con.Close();
return serializer.Serialize(rows);
}
 
 
using above code  in jqurey i need to preapre chart can any one give me solution 
 
thanks in advance 

Answers (2)