Click here to Skip to main content
16,019,043 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
after i convert a datatable into a list
its shows a error

var datas = dtcombo;
                               ColumnSeries col = new ColumnSeries() { DataLabels = true, Values = new ChartValues<int>(), LabelPoint = Point => Point.Y.ToString() };
                               Axis ax = new Axis() { Separator = new Separator() { Step = 1, IsEnabled = false } };
                               ax.Labels = new List<string>();

                                       foreach (var x in datas)
                                       {
                                           col.Values.Add(x.total.value);
                                           ax.Labels.Add(x.year.ToString());

                                       }


its for bind the datatable values to a livechart
please help

What I have tried:

using foreach its shows error

foreach statement cannot operate on variables of type 'system.data.datatable'...
Posted
Updated 24-Jan-18 19:49pm
Comments
VR Karthikeyan 25-Jan-18 1:24am    
What is the type of dtcombo?

1 solution

A DataTable can't be iterated, because it's not a collection.
Probably you meant to access it's rows:
foreach (var x in datas.Rows)
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900