MSChart state management
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:
- By using
the chart ViewState, but ViewState have its own problems.
Before enabling ViewState
After enabling ViewState
<asp:Chart ID="Chart1" runat="server"
You can see the difference in bytes size.
By again re-populate the chart with data from
database. On every post back we need to use this.
Or save the dataset/datatable and later use
Another efficient way is by saving the
Chart into a file. It can be binary or xml.
using Charting SerializationFormat, refer msdn URL for more information.
Sample code attached, Please post your