Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8178477
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T23:46:35+00:00 2026-06-06T23:46:35+00:00

I dynamically create several gauge controls store them to a class, and then add

  • 0

I dynamically create several gauge controls store them to a class, and then add them to a list and session variable for retrieval later. When I attempt to load the gauges from the session state some of the control attributes are not set, as an example ‘gauge.Gauge.Value’ threw an exception of type ‘System.NullReferenceException’. My class looks like this:

public BoldGauge(ASPxGaugeControl gauge, string gaugeValue, string gaugeDataType, float gaugeMinValue, float gaugeMaxValue)
    {
        Gauge = gauge; // new ASPxGaugeControl(); 
        GaugeValue = gaugeValue; 
        GaugeDataType = gaugeDataType; 
        GaugeMinValue = gaugeMinValue; 
        GaugeMaxValue = gaugeMaxValue; 
    }

    public ASPxGaugeControl Gauge { get; set; }
    public string GaugeValue { get; set; } 
    public string GaugeDataType { get; set; } 
    public float GaugeMinValue { get; set; }
    public float GaugeMaxValue { get; set; } 
}

Heres how I declare my controls, and toward the bottom you can see where I add them, to the list, and session. Any ideas why this is occuring? Do I need to do something special to store a control in session?

ASPxDockPanel dockPanel = CreateDockPanel(layoutName, tableCellId, controlType, controlData, controlName);
            ASPxGaugeControl boldGaugeControl = new ASPxGaugeControl();

            string dockZonePanelId = "dockPanel" + tableCellId[tableCellId.Length - 1] + layoutName.Replace(".xml", "");
            //boldGaugeControl.ID = "gaugeControl" + dockZonePanelId;

            boldGaugeControl.ID = "gaugeControl" +gaugeVal; 
            boldGaugeControl.ClientInstanceName = "gaugeControl" +gaugeVal; // +gaugeVal;// dockZonePanelId  + layoutName.Replace(".xml", "");
            boldGaugeControl.EnableClientSideAPI = true;

            // Creates a new instance of the CircularGauge class and adds it
            // to the gauge control's Gauges collection.
            CircularGauge circularGauge = (CircularGauge)boldGaugeControl.AddGauge(GaugeType.Circular);

            // Adds the default elements (a scale, background layer, needle and spindle cap).
            circularGauge.AddDefaultElements();

            // Changes the background layer's paint style.
            ArcScaleBackgroundLayer background = circularGauge.BackgroundLayers[0];
            background.ShapeType = BackgroundLayerShapeType.CircularFull_Style2;

            // Customizes the scale's settings.
            ArcScaleComponent scale = circularGauge.Scales[0];
            scale.MinValue = minimumGaugeValue;
            scale.MaxValue = maximumGaugeValue;
            scale.Value = value;
            scale.MajorTickCount = 6;
            scale.MajorTickmark.FormatString = "{0:F0}";
            scale.MajorTickmark.ShapeType = TickmarkShapeType.Circular_Style1_2;
            scale.MajorTickmark.ShapeOffset = -9;
            scale.MajorTickmark.AllowTickOverlap = true;
            scale.MinorTickCount = 3;
            scale.MinorTickmark.ShapeType = TickmarkShapeType.Circular_Style2_1;
            scale.AppearanceTickmarkText.TextBrush = new SolidBrushObject(Color.Gray);

            // Changes the needle's paint style.
            ArcScaleNeedleComponent needle = circularGauge.Needles[0];
            needle.ShapeType = NeedleShapeType.CircularFull_Style3;

            // Adds the gauge control to the Page.
            boldGaugeControl.Width = 150;
            boldGaugeControl.Height = 150;
            boldGaugeControl.AutoLayout = true;
            boldGaugeControl.ControlStyle.BackColor = Color.Black;
            boldGaugeControl.EnableClientSideAPI = true;
            boldGaugeControl.ClientIDMode = ClientIDMode.Static;
            boldGaugeControl.Value = "25";

            dockPanel.Controls.Add(boldGaugeControl);

            BoldGauge gauge = new BoldGauge(boldGaugeControl, gaugeValue, controlData, minimumGaugeValue, maximumGaugeValue);

            boldGauges.Add(gauge);
            Session.Add("GaugesList", boldGauges);

I attempt to retrieve them in this call, which does get the values, but not all attributes are

protected void UpdateGauges()
    {

        List<BoldGauge> boldGauges = (List<BoldGauge>)Session["GaugesList"];

        if (boldGauges != null)
        {
            foreach (BoldGauge gauge in boldGauges)
            {
                ArcScaleComponent scale = GetGaugeScale(gauge.Gauge, 0, 0);
                scale.BeginUpdate();
                float newValue = new Random().Next(100);
                scale.Value = newValue;
                scale.EndUpdate();
            }
        }
    }
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-06T23:46:36+00:00Added an answer on June 6, 2026 at 11:46 pm

    Behavior is semi-expected – just don’t do that.

    Storing non-serializable objects in session state is generally not a god idea. It mostly works in case of in-proc provider and totally fails when using SQL provider.

    In addition storing controls that expect page object to be around will not work when taken out from session state on next request since old Page (or parent control) object is destroyed along with previous requests. The control is also could have de-initialized itself since its parent is destroyed.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I need to create several Divs dynamically, and I need to add onmouseover event
I just want to add ContextMenu for several objects that I create dynamically, but
I have a directory on my website with several mp3's. I dynamically create a
I have dynamically created WrapPanel (_wp) with several Borders. And I need create handler
Am attempting to dynamically create html which then injects itself as an iframe into
I want to dynamically create instance method of child class through class method of
I want to create several properties on the fly inside the class' constructor and
Only Teradata SQL is available for use. I'm trying to dynamically create a list
Am having several boxes(more than 100) that will create dynamically with <div id=window5></div> <div
Am having several boxes(more than 100) that will create dynamically with <div id=window5></div> <div

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.