How to set asp net chart control ChartType property dynamically

preview_player
Показать описание
Text version of the video

Healthy diet is very important both for the body and mind. If you like Aarvi Kitchen recipes, please support by sharing, subscribing and liking our YouTube channel. Hope you can help.

Slides

ASP.NET Charts Playlist

All ASP .NET Chart Control Text Articles and Slides

All Dot Net and SQL Server Tutorials in English

All Dot Net and SQL Server Tutorials in Arabic

There are 2 ways to set the ChartType property

1. Declaratively in the HTML using ChartType attribute as shown below.
[Series]
[asp:Series Name="Series1" ChartArea="ChartArea1" ChartType="Pie"]
[Points]
[asp:DataPoint AxisLabel="Mark" YValues="800,0,0,0,0,0" /]
[asp:DataPoint AxisLabel="Steve" YValues="900,0,0,0,0,0" /]
[asp:DataPoint AxisLabel="John" YValues="700,0,0,0,0,0" /]
[asp:DataPoint AxisLabel="Mary" YValues="900,0,0,0,0,0" /]
[asp:DataPoint AxisLabel="Ben" YValues="600,0,0,0,0,0" /]
[/Points]
[/asp:Series]
[/Series]

2. Programatically in code. We want to display all the different ChartTypes available in a DropDownList. When the user selects an option from the DropDownList we want to set the selected chart type as the value for the ChartType property dynamically in code.

[div style="font-family:Arial"]
[table style="border: 1px solid black"]
[tr]
[td]
[b]Select Chart Type :[/b]
[/td]
[td]
[asp:DropDownList ID="ddlChartType" runat="server" AutoPostBack="True"
onselectedindexchanged="ddlChartType_SelectedIndexChanged"]
[/asp:DropDownList]
[/td]
[/tr]
[tr]
[td colspan="2"]
[asp:Chart ID="Chart1" runat="server" Width="350px"]
[Titles]
[asp:Title Text="Total marks of students"]
[/asp:Title]
[/Titles]
[Series]
[asp:Series Name="Series1" ChartArea="ChartArea1" ChartType="Pie"]
[Points]
[asp:DataPoint AxisLabel="Mark" YValues="800,0,0,0,0,0" /]
[asp:DataPoint AxisLabel="Steve" YValues="900,0,0,0,0,0" /]
[asp:DataPoint AxisLabel="John" YValues="700,0,0,0,0,0" /]
[asp:DataPoint AxisLabel="Mary" YValues="900,0,0,0,0,0" /]
[asp:DataPoint AxisLabel="Ben" YValues="600,0,0,0,0,0" /]
[/Points]
[/asp:Series]
[/Series]
[ChartAreas]
[asp:ChartArea Name="ChartArea1"]
[AxisX Title="Student Name"]
[/AxisX]
[AxisY Title="Total Marks"]
[/AxisY]
[/asp:ChartArea]
[/ChartAreas]
[/asp:Chart]
[/td]
[/tr]
[/table]
[/div]
Рекомендации по теме
Комментарии
Автор

thank you so much sir Your Video series are world best series thanks a lot

pushpakgosavi
Автор

Hi Sir, I am currently using your tutorial video to implement two graghs from a local database, which does work. However, once I choose a chart type it changes it for one gragh but then does not display data on the other gragh any suggestions on why this might be? Any help would be appreciated.

gunit
Автор

Hello Thanks for uploading this tutorial. Sir I have followed all your steps but I'm getting blank when choosing any other type of chart. Please help!

sandiachanchal
Автор

To avoid getting blank when chart type is changed, Add a GetChartdata() to protected void

jbunjo
Автор

hii  sir please upload  some videos on membership in asp.net. like  role management, change password, role based security  using membership

it is very  frequently asked question in almost each  interview(for security module person) 

manishkumar-whnw
Автор

If your dropdown menu is not working, you need to add into the dropmenu list tag in the html.

richardyang
Автор

hi sir
 i follow your every video tutorial.but i m not able to add chart control in toolbox.there is two version of chart control that is axle type 

Rajbirsingh-qvfi
Автор

HI  sir please upload  some videos on membership in asp.net. like  role management, change password, role based security  using membership

it is very  frequently asked question in almost each  interview(for security module person) .

jeewanintube
Автор

Dude i followed your steps but apparently the codes in the SelectedIndexChanged event does not work anymore. It gives me blank when i choose another value. Please help.

mohammadshaqilbinsamuelwon
visit shbcf.ru