Click here to Skip to main content
11,799,282 members (75,194 online)
Rate this: bad
Please Sign up or sign in to vote.
I have created a user control which has a chart to display employee statistics over a period of time. I have used MSChart. I have 3 different series and i want to switch between them at runtime so that the user has an option to view different statistics. I have used legenditem and using it's postback value, I have parsed it. I have put all of this in an UpdatePanel

The problem is that whenever I click on the legendItem, the control is reloaded and the Chart Area becomes blank. Here is my code. Please help me.

protected void Chart1_Click(object sender, ImageMapEventArgs e)
            // If user clicks on the map area attribute that corresponds to a legend item
            if (e.PostBackValue.StartsWith("LegendClick"))
                string args = e.PostBackValue.Split('/')[1];
                // Identify which legend item was clicked
                int index = int.Parse(args);
                // Legend item result
                LegendItem legendItem = this.Chart1.Legends[0].CustomItems[index];
                // Resets all radio button images to be unchecked
                /* foreach (LegendItem item in this.Chart1.Legends[0].CustomItems)
                     item.Cells[0].ImageTransparentColor = Color.Black;
                     item.Cells[0].Image = "radio_button_unchecked.gif";
                for (; ; )
                    switch (legendItem.Cells[1].Text)
                        case "Points":
                            this.Chart1.Series["series1"].Enabled = true;
                            this.Chart1.Series["series2"].Enabled = false;
                            this.Chart1.Series["series3"].Enabled = false;
                            this.Chart1.Series[0].ChartType = (SeriesChartType)Enum.Parse(typeof(SeriesChartType), "Line", true);
                            this.Chart1.Legends[0].CustomItems[0].Cells[0].Image = "radio_button_checked.gif";
                        case "CSAT":
                            this.Chart1.Series["series1"].Enabled = false;
                            this.Chart1.Series["series2"].Enabled = true;
                            this.Chart1.Series["series3"].Enabled = false;
                            this.Chart1.Legends[0].CustomItems[1].Cells[0].Image = "radio_button_checked.gif";
                        case "SLA":
                            this.Chart1.Series["series1"].Enabled = false;
                            this.Chart1.Series["series2"].Enabled = false; ;
                            this.Chart1.Series["series3"].Enabled = true;
                            this.Chart1.Legends[0].CustomItems[2].Cells[0].Image = "radio_button_checked.gif";
Posted 17-Oct-12 19:37pm
Edited 17-Oct-12 20:51pm
lukeer at 18-Oct-12 2:36am
Use the "Improve question" link just below your question to provied further detail, be it of circumstances, error messages or whatever.

Don't create a new question for that. That way you more likely get a usable answer.

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

  Print Answers RSS
0 OriginalGriff 473
1 CPallini 410
2 Richard MacCutchan 319
3 phil.o 244
4 Kornfeld Eliyahu Peter 205
0 OriginalGriff 2,475
1 Maciej Los 1,860
2 KrunalRohit 1,496
3 CPallini 1,465
4 Richard MacCutchan 1,149

Advertise | Privacy | Mobile
Web02 | 2.8.151002.1 | Last Updated 18 Oct 2012
Copyright © CodeProject, 1999-2015
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100