Click here to Skip to main content
15,891,905 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi, I am trying to bind and display ajax chart on my web page. But doesn't shows any out put. Please help me.

C#
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using System.Data.SqlClient;
using System.Configuration;

public partial class demo2 : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            DataTable dt = new DataTable();
            SqlConnection con = new SqlConnection(@"connectionString);
            SqlCommand cmd=new SqlCommand("select Name, Debit, Credit From aTable",con);
            SqlDataAdapter da=new SqlDataAdapter (cmd);
            da.Fill(dt);
        string[] x = new string[dt.Rows.Count];
        decimal[] z = new decimal[dt.Rows.Count];
        decimal[] y = new decimal[dt.Rows.Count];
        for (int i = 0; i < dt.Rows.Count; i++)
        {
                x[i] = dt.Rows[i][0].ToString();
                y[i] = Convert.ToInt32(dt.Rows[i][1]);
                z[i] = Convert.ToInt32(dt.Rows[i][2]);
        }
            BarChart1.Series.Add(new AjaxControlToolkit.BarChartSeries { Data = y });
            BarChart1.Series.Add(new AjaxControlToolkit.BarChartSeries { Data = z });
            BarChart1.CategoriesAxis = string.Join(",", x);
       }
    }
}
Posted

1 solution

Once go through these links.

1. Display and bind AJAX Bar Chart inside ASP.Net GridView[^]

2. ASP.Net AJAX Bar Chart Control: Populate from Database example[^]


[Edit member="Tadit"]
Link text added to reflect the Article/QA title.
[/Edit]
 
Share this answer
 
v4
Comments
Member 11042100 1-Oct-14 3:08am    
I searched all these links.
I don't want to use any drop down or grid on my chart.
I have to dynamically bind with the data base and display it on my web page. Please help me. Any one know what is the error on above code.

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