I have a database created taking some survey values and i want to creat a pie chart based on the survey through asp.net. please help me.
SqlConnection con;
SqlDataAdapter da;
DataTable dt;
DataSet ds = new DataSet();
protected void Page_Load(object sender, EventArgs e)
{
if(!IsPostBack)
{
con=new SqlConnection("server=DELL-PC;database=mproject;uid=sa;pwd=pass");
Chart1.Visible = true;
string qry1 = "select * from chart";
da=new SqlDataAdapter(qry1,con);
da.Fill(ds);
string[] x = new string[ds.Tables[0].Rows.Count];
string[] y = new string[ds.Tables[0].Rows.Count];
for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
{
x[i] = ds.Tables[0].Rows[i][0].ToString();
y[i]= ds.Tables[0].Rows[i][1].ToString();
}
Chart1.Series[0].Points.DataBindXY(x, y);
Chart1.Legends[0].Enabled = true;
}
}