I followed your article to display pie chart
Populate ASP.Net 4.0 Chart Control Pie Chart from SQL Server Database
it is showing me error on this following line
Chart1.Series[0].ChartType = SeriesChartType.Pie;
Compiler Error Message: CS0103: The name 'SeriesChartType' does not exist in the current context
I am using Visual Studio 2010.
private void BindGrid()
{
con = new SqlDbConnect();
con.SqlQuery(@"select 'Dispatch Local' as 'Head',Sum(TotalPrice) 'Amount' from tblDispatchLocal
union all
select 'Sales Trans:' as 'Head',Sum(P_Price) 'Amount' from tblSalesTran
;");//union all select 'Loan Recovery:' as 'Head',Sum(R_Amount) 'Amount' from tblLoanRefund;
adapt.SelectCommand = con.Cmd;
adapt.Fill(sTable);
if (sTable.Rows.Count > 0)
{
GridView1.DataSource = sTable;
GridView1.DataBind();
GridView1.FooterRow.Cells[0].Text = "Total:";
GridView1.FooterRow.Cells[0].Font.Bold = true;
GridView1.FooterRow.Cells[0].HorizontalAlign = HorizontalAlign.Right;
decimal totalDis = sTable.AsEnumerable().Sum(row => row.Field<decimal>("Amount"));
GridView1.FooterRow.Cells[1].Text = totalDis.ToString();
GridView1.FooterRow.Cells[1].HorizontalAlign = HorizontalAlign.Center;
GridView1.FooterRow.Cells[1].Font.Bold = true;
GridView1.FooterRow.Cells[1].BackColor = System.Drawing.Color.Yellow;
string[] x = new string[sTable.Rows.Count];
decimal[] y = new decimal[sTable.Rows.Count];
for (int i = 0; i < sTable.Rows.Count; i++)
{
x[i] = sTable.Rows[i][0].ToString();
y[i] = Convert.ToDecimal(sTable.Rows[i][1].ToString());
}
Chart1.Series[0].Points.DataBindXY(x, y);
Chart1.Series[0].ChartType = SeriesChartType.Pie;
Chart1.ChartAreas["ChartArea1"].Area3DStyle.Enable3D = true;
Chart1.Legends[0].Enabled = true;
}
}
How to fix this issue plz.