Click here to Skip to main content
13,054,615 members (64,242 online)
Rate this:
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
Updated 17-Oct-12 20:51pm
lukeer 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
Top Experts
Last 24hrsThis month

Advertise | Privacy | Mobile
Web02 | 2.8.170713.1 | Last Updated 18 Oct 2012
Copyright © CodeProject, 1999-2017
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