This is a migrated thread and some comments may be shown as answers.

Index was out of range exception on legend click

1 Answer 58 Views
Chart (Obsolete)
This is a migrated thread and some comments may be shown as answers.
mary
Top achievements
Rank 1
mary asked on 08 Dec 2008, 03:06 PM
Hi
I've set up onclick handler for the chart to enable the user to click on the bars and get  detail info on the series item (the items are added programmatically and this seems to be the only was to to handle the click).  Is there a way to prevent the onclick event firing when the user clicks on the legend?  I'm getting the followin exception:

Index was out of range. Must be non-negative and less than the size of the collection.
Parameter name: index

Thanks

1 Answer, 1 is accepted

Sort by
0
Giuseppe
Telerik team
answered on 10 Dec 2008, 11:42 AM
Hi mary,

You can detect whether click occurred for series item elements like this:

protected void RadChart1_Click(object sender, ChartClickEventArgs args) 
    if (args.SeriesItem != null) 
    { 
        Response.Write("Series Item Clicked"); 
    } 

Alternatively, you can use the approach described here to disable click for certain chart elements (the same pattern works for legend).


Greetings,
Manuel
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
Tags
Chart (Obsolete)
Asked by
mary
Top achievements
Rank 1
Answers by
Giuseppe
Telerik team
Share this question
or