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:
iam using a datatable bind the values to live chart
C#
DataTable dtcombo = new DataTable();
dtcombo = objG.GraphReport();

 var datas = dtcombo.AsEnumerable();
                                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.particulars.ToString());
                                            ax.Labels.Add(x.year.ToString());

                                        }


but shows a error at these position
C#
col.Values.Add(x.particulars.ToString());
 ax.Labels.Add(x.year.ToString());


its shows system.data.datarow does not contain defenition.....

anybody knows please help me...

What I have tried:

tried datatable converted to list
Posted
Updated 24-Jan-18 20:04pm

1 solution

DataRow objects do not contain properties for each of your columns: you need to access teh column via an index:
col.Values.Add(x[0].ToString());
Or by name:
col.Values.Add(x["particulars"].ToString());
 
Share this answer
 
Comments
Jaison Joseph 25-Jan-18 2:16am    
its shows invalid castexpression....Specified cast is not valid.

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