tags:

views:

177

answers:

2

Hi,

I want to parse the ChartType from a dropdown list but I couldnt parse the value, Is there anyway to parse it ?

using System.Web.UI.DataVisualization.Charting;
...
...
Chart2.Series[0].ChartType = Enum.Parse(typeof(SeriesChartType.Area), DropDownList1.Text);

Thx in advance!

+1  A: 

You probably don't want to specify .Area:

Chart2.Series[0].ChartType = Enum.Parse(typeof(SeriesChartType), DropDownList1.Text);
_rusty
A: 

You could populate the DropDownList1 with the enumeration.

The string representation of the enumeration name would be displayed as the text in DropDownList1.

DropDownList1.Items.AddRange = Enum.GetValues(typeof(SeriesChartType));

Then you can access the items of the list.

Chart2.Series[0].ChartType = (SeriesChartType)DropDownList1.SelectedItem;

gooch