Click here to Skip to main content
15,886,806 members

MSChart becomes blank after update

Member 9308433 asked:

Open original thread
Hi, I have a user control which contains an MSChart. I have a drop down list using which I want to select series that I have defined in the code behind. I have used Update Panels, both in the Chart Area as well as on the main .aspx page. After raising the "OnSelectedIndexChanged" event I used a Delegate to Update the UpdatePanel in the .aspx page as well as using Update() in the .ascx page. The chart does not refresh with the new series and just remains blank.

Here is the relevant code

.ascx file
C#
protected void ChangeSeries(object sender, EventArgs e)
        {
            string series_selected = dd1.SelectedIndex.ToString();

                       
            switch (series_selected)
            {
                case ("Points"):
                    Series series1 = Chart1.Series[0];
                    this.FillStockDataPoints(series1, 5.0, DateTime.Now);
                    this.Chart1.Series["series1"].ChartType = System.Web.UI.DataVisualization.Charting.SeriesChartType.Line;
                    Chart1.Series[0]["PixelPointWidth"] = "25";
                    _delUpdateControl.DynamicInvoke();
                   UpdatePanel1.Update() 
                    
                    break;

                case ("CSAT"):
                    Series series2 = Chart1.Series[1];
                    this.FillStockDataCSAT(series2, 5.0, DateTime.Now);
                    Chart1.Series[1]["PixelPointWidth"] = "25";
                    this.Chart1.Series["series2"].ChartType = System.Web.UI.DataVisualization.Charting.SeriesChartType.Column;
                    _delUpdateControl.DynamicInvoke();
                    UpdatePanel1.Update()
                    break;

                case ("SLA"):
                    Series series3 = Chart1.Series[2];
                    this.FillStockDataSLA(series3, 5.0, DateTime.Now);
                    Chart1.Series[2]["PixelPointWidth"] = "25";
                    this.Chart1.Series["series3"].ChartType = System.Web.UI.DataVisualization.Charting.SeriesChartType.Column;
                    _delUpdateControl.DynamicInvoke();
                    UpdatePanel1.Update()
                    break;
            }


This is the Dynamic Invoke Delegate:

SQL
public void UpdateStatsControl()
        {
            this.UpdatePanelStats.Update();
            StatsControl.InitializeStatsControl();

        }


Please tell me a way to refresh and reload the Chart after selecting the required series in the DropDownList.

HELP!!!!
Tags: C#, Ajax, ASP.NET, Chart

Plain Text
ASM
ASP
ASP.NET
BASIC
BAT
C#
C++
COBOL
CoffeeScript
CSS
Dart
dbase
F#
FORTRAN
HTML
Java
Javascript
Kotlin
Lua
MIDL
MSIL
ObjectiveC
Pascal
PERL
PHP
PowerShell
Python
Razor
Ruby
Scala
Shell
SLN
SQL
Swift
T4
Terminal
TypeScript
VB
VBScript
XML
YAML

Preview



When answering a question please:
  1. Read the question carefully.
  2. Understand that English isn't everyone's first language so be lenient of bad spelling and grammar.
  3. If a question is poorly phrased then either ask for clarification, ignore it, or edit the question and fix the problem. Insults are not welcome.
  4. Don't tell someone to read the manual. Chances are they have and don't get it. Provide an answer or move on to the next question.
Let's work to help developers, not make them feel stupid.
Please note that all posts will be submitted under the http://www.codeproject.com/info/cpol10.aspx.



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900