April 17th, 2014, 04:11 AM
[RESOLVED] Multiple datatables to single chart
I have an application that displays data into a chart. There are several data sources (datatables) & each source is evaluated as a separate chart. There is one chart visual element in the application & the data source (datatable) is selected from a combobox drop down list thus updating the visuals.
I am using the code below to pass the data from the datatable to the chart elements :-
foreach (DataRow row in tableFirst.Rows)
int i = Convert.ToInt32(row);
series1.Points.Add(new SeriesPoint(i, row));
series2.Points.Add(new SeriesPoint(i, row));
All works OK until I need to change the datatable (i.e.:- the user selects a different data source option / wants to see a different report). I could repeat the above code block for each of the data sources (15) but to my mind thats an inelegant solution & adds too much redundant code.
My question is :-
How do I achieve the above but pass the new datatable name to the code block when the user selects a different option?
Click Here to Expand Forum to Full Width
This is a CodeGuru survey question.