Solved
Dundas Chart - how to check if a Chart Series exists before manipulating it?
Posted on 2006-11-09
I'm creating a reusable sub to add formatting to 2 chart series within a Dundas Chart. Occasionally however, the second series doesn't actually exist (based on the data returned from a datatable), so I am getting an Invalid Argument exception when I try the following code. Can any help show me how to avoid this error?
<DCWC:Chart ID="Chart1" runat="server">
<Series>
<DCWC:Series Name="Default" />
<DCWC:Series Name="Totals" />
</Series>
<ChartAreas>
<DCWC:ChartArea Name="Default" />
</ChartAreas>
</DCWC:Chart>
If Chart1.Series("Totals") IsNot Nothing Then ' <-- error here: Data series with name "Totals" was not found in the series collection
' perform chart colouring functions
End If