asp.net chart control :
* Add Refrence
System.Data.DataVisualization
aspx :
<%@ Register assembly="System.Web.DataVisualization, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
namespace="System.Web.UI.DataVisualization.Charting" tagprefix="AChart" %>
<div>
<AChart:Chart ID="ChartID" runat="server" Width="345px" >
<series>
<AChart:Series Name="Series1" ChartType="Pie">
</AChart:Series>
</series>
<chartareas>
<AChart:ChartArea Name="ChartArea1">
</AChart:ChartArea>
</chartareas>
</AChart:Chart>
</div>
aspx.cs :
Add Namespace :
using System.Web.UI.DataVisualization;
using System.Web.UI.DataVisualization.Charting;
SqlConnection objConn = new
SqlConnection(ConfigurationManager.AppSettings["Connection"]);
SqlDataAdapter objDa = new SqlDataAdapter();
string Select;
Select = "Select Act_ID,Act_Name,Act_salary From Actor";
objDa = new SqlDataAdapter(Select, objConn);
DataSet ds = new DataSet();
objDa.Fill(ds);
ChartID.DataSource = ds;
ChartID.Legends.Add("Actor").Title = "Student Sample";
ChartID.Series["Series1"].XValueMember = "Act_Name";
--Column Name
ChartID.Series["Series1"].YValueMembers = "Act_salary";
--Column Name
ChartID.DataBind();
----------------------------------------------
-----------------------------------------------
No comments:
Post a Comment