SIGN UP MEMBER LOGIN:    
ARTICLE

MSChart State Management

Posted by Suthish Nair Articles | Current Affairs August 30, 2010
MSChart have a problem of maintaining data state during post back. When a post back happens the Chart will get blank or data get cleared.
Reader Level:
Download Files:
 

MSChart have a problem of maintaining data state during post back. When a post back happens the Chart will get blank or data get cleared.

Typically charts are used to provide a presentation of data in graphical manner. How can we make the chart object persist its data during post back? There are couple of ways:

1. By using the chart ViewState, but ViewState have its own problems.

Before enabling ViewState

MSChart1.gif

After enabling ViewState

<asp:Chart ID="Chart1" runat="server" EnableViewState="true">

MSChart2.gif

You can see the difference in bytes size.

2. By again re-populate the chart with data from database. On every post back we need to use this.

3. Or save the dataset/datatable and later use for rebinding.

4. Another efficient way is by saving the Chart into a file. It can be binary or xml.

By using Charting SerializationFormat, refer msdn URL for more information.

http://msdn.microsoft.com/en-us/library/system.web.ui.datavisualization.charting.serializationformat.aspx

Sample code attached, Please post your responses.

Login to add your contents and source code to this article
share this article :
post comment
 
6 Months Free & No Setup Fees ASP.NET Hosting!
Become a Sponsor
PREMIUM SPONSORS
  • Finally – a virtual platform that delivers next-generation Windows Server 2008 Hyper-V virtualization technology from a managed hosting partner you can truly depend on. Visit www.maximumasp.com/max for a FREE 30 day trial. Hurry offer ends soon. Climb aboard the MaxV platform and take advantage of High Availability, Intelligent Monitoring, Recurrent Backups, and Scalability – with no hassle or hidden fees. As a managed hosting partner focused solely on Microsoft technologies since 2000, MaximumASP is uniquely qualified to provide the superior support that our business is built on. Unparalleled expertise with Microsoft technologies lead to working directly with Microsoft as first to offer IIS 7 and SQL 2008 betas in a hosted environment; partnering in the Go Live Program for Hyper-V; and product co-launches built on WS 2008 with Hyper-V technology.
    The leading .NET charting control now features PDF, Flash and Silverlight export, visualization of large datasets and more. Deliver true charting functionality to your BI, Scorecard, Presentation or Scientific apps. Download evaluation now.
Nevron Gauge for SharePoint
Become a Sponsor