How to Create BarChart based on DB data in Asp.net [Resolved]

Posted by Santhoshalla under ASP.NET on 2/14/2013 | Points: 10 | Views : 41121 | Status : [Member] | Replies : 4
Please any body help me
how to create barchart/Pie chart using asp.net based on database data




Responses

Posted by: Kusumas on: 2/14/2013 [Member] Starter | Points: 50

Up
0
Down

Resolved
Hi,

Aspx:
<asp:Chart ID="Chart1" runat="server" Palette="EarthTones">
<Series>
<asp:Series Name="Series1" ChartType="Bar" XValueMember="AutoID" YValueMembers="Price">
</asp:Series>
</Series>
<ChartAreas>
<asp:ChartArea Name="ChartArea1">
</asp:ChartArea>
</ChartAreas>
</asp:Chart>

C#:

DataTable dt = new DataTable();
using (SqlConnection cn = new SqlConnection(Constr))
{
string sql = "select * from Chart";
using (SqlCommand cmd = new SqlCommand(sql, cn))
{
using (SqlDataAdapter da = new SqlDataAdapter(cmd))
{
da.Fill(dt);
}

}
}
Chart1.DataSource = dt;
Chart1.DataBind();

you want display in Pie chart use below code
<asp:Series Name="Series1" ChartType="Bar" XValueMember="AutoID" YValueMembers="Price" ChartType ="pie" >
</asp:Series>



Thanks,

Santhoshalla, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Santhoshalla on: 2/14/2013 [Member] Starter | Points: 25

Up
0
Down
Thank You so Much.


please can you share me any typical solution Your free time.






Santhoshalla, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Kusumas on: 2/14/2013 [Member] Starter | Points: 25

Up
0
Down
ok i will....

if my answer is useful to you mark as resolved......

Santhoshalla, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Salman on: 2/15/2013 [Member] Starter | Points: 25

Up
0
Down
Thx i was also finding a solution for the same but can u let me know if i add a chart control to aspx page is there any settings to be done in we.config file

Salman Farooqui

Santhoshalla, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response