use following demo for chart control.....
on .aspx page:
<%@ Register Assembly="System.Web.DataVisualization, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
Namespace="System.Web.UI.DataVisualization.Charting" TagPrefix="asp" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:Chart ID="chartForMarks" runat="server" Width="500px">
<Series>
<asp:Series Name="NumberInMath" XValueMember="Name" YValueMembers="NumberInMath"
IsVisibleInLegend="true" ChartType="Pie">
</asp:Series>
</Series>
<ChartAreas>
<asp:ChartArea Name="ChartArea1" Area3DStyle-Enable3D="true">
<AxisX LineColor="DarkGreen">
<MajorGrid LineColor="LightGreen" />
</AxisX>
<AxisY LineColor="DarkGreen">
<MajorGrid LineColor="LightGreen" />
</AxisY>
<Area3DStyle Enable3D="True"></Area3DStyle>
</asp:ChartArea>
</ChartAreas>
<Legends>
<asp:Legend>
</asp:Legend>
</Legends>
</asp:Chart>
</div>
</form>
</body>
</html>
on .cs page:
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
CreatePIChartForMarks();
}
}
private void CreatePIChartForMarks()
{
var table = new DataTable();
table.Columns.Add("Name", typeof(string));
table.Columns.Add("NumberInMath", typeof(long));
table.Columns.Add("Lbl");
var row = table.NewRow();
row["Name"] = "Girijesh";
row["NumberInMath"] = 33;
table.Rows.Add(row);
row = table.NewRow();
row["Name"] = "Rajesh";
row["NumberInMath"] = 09;
table.Rows.Add(row);
row = table.NewRow();
row["Name"] = "Pallav";
row["NumberInMath"] = 98;
table.Rows.Add(row);
row = table.NewRow();
row["Name"] = "Sharath";
row["NumberInMath"] = 37;
table.Rows.Add(row);
row = table.NewRow();
row["Name"] = "Mahesh";
row["NumberInMath"] = 59;
table.Rows.Add(row);
row = table.NewRow();
row["Name"] = "Lokesh";
row["NumberInMath"] = 78;
table.Rows.Add(row);
chartForMarks.DataSource = table;
chartForMarks.DataBind();
}
JMD:-)