Solved

Why does my graph lose its data?

Posted on 2014-11-24
12
166 Views
Last Modified: 2015-01-25
I'm using chart director to load two graphs with data on my .aspx page. I'm having trouble holding onto the data for my 2nd graph. The graph at the top of my page seems to hold onto its data during a postback, but the graph 2nd graph loses data when the page posts back and i'm not sure why.

I load a few  drop down lists in my Page_Load event:

        if (!IsPostBack)
        {
            LoadBranches();
            LoadMetros();
            LoadRegYears();
        }

Open in new window


here is my HTML:

<%@ Page Title="Quarterly Registrations By Year" Language="C#" MasterPageFile="SiteDetailPage.master"
    AutoEventWireup="true" CodeFile="QuarterlyRegistrations.aspx.cs" Inherits="VolumeChartModMakeYear" %>

<%@ Register TagPrefix="chart" Namespace="ChartDirector" Assembly="netchartdir" %>
<asp:Content ID="Content1" ContentPlaceHolderID="HeadContent" runat="Server">
    <style type="text/css">
        .style1
        {
            width: 100%;
        }
        .style3
        {
            text-align: right;
        }
        .style4
        {
            text-align: left;
            width: 50%;
        }
    </style>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="Server">
    <asp:ScriptManager ID="ScriptManager1" runat="server" />
    <%--<asp:UpdatePanel ID="udpnlUsedRegs" runat="server">
                                <ContentTemplate>--%>
    <%--</ContentTemplate>
                            </asp:UpdatePanel>--%>
    <table class="style1">
        <tr>
            <td>
                <table align="center" class="style1">
                    <tr>
                        <td class="style3">
                            Select a Branch
                        </td>
                        <td class="style4">
                            <asp:DropDownList ID="ddlBranch" runat="server" OnSelectedIndexChanged="ddlBranch_SelectedIndexChanged">
                            </asp:DropDownList>
                        </td>
                    </tr>
                    <tr>
                        <td class="style3">
                            OR Select a Metro
                        </td>
                        <td class="style4">
                            <asp:DropDownList ID="ddlMetro" runat="server" Width="200px" OnSelectedIndexChanged="ddlMetro_SelectedIndexChanged">
                            </asp:DropDownList>
                            <asp:Button ID="btnUsedRegistrations" runat="server" OnClick="btnUsedRegistrations_Click"
                                Text="Show Graph" />
                        </td>
                    </tr>
                    <tr>
                        <td colspan="2">
                            <table class="style1">
                                <tr>
                                    <td>
                                        <asp:Label ID="errMsg" runat="server" Text="" Font-Bold="true" ForeColor="#CC0000" />
                                    </td>
                                </tr>
                                <tr>
                                    <td style="text-align: center">
                                    </td>
                                </tr>
                                <tr>
                                    <td style="text-align: center">
                                        <chart:WebChartViewer ID="WebChartViewer1" runat="server" />
                                    </td>
                                </tr>
                            </table>
                        </td>
                    </tr>
                </table>
            </td>
        </tr>
        <tr>
            <td>
            </td>
        </tr>
        <tr>
            <td>
            </td>
        </tr>
        <tr>
            <td>
                &nbsp;
                <table align="center" class="style1">
                    <tr>
                        <td>
                            <asp:UpdatePanel ID="udPnlMetro" runat="server">
                                <ContentTemplate>
                                    <table align="center" class="style1">
                                        <tr>
                                            <td>
                                                <table align="center" class="style1">
                                                    <tr>
                                                        <td class="style3">
                                                            Branch:
                                                        </td>
                                                        <td class="style4">
                                                            <asp:DropDownList ID="ddlMetroBranch" runat="server" Style="margin-left: 0px">
                                                            </asp:DropDownList>
                                                        </td>
                                                    </tr>
                                                </table>
                                            </td>
                                        </tr>
                                        <tr>
                                            <td>
                                                <table align="center" class="style1">
                                                    <tr>
                                                        <td class="style3">
                                                            Reg. Year:
                                                        </td>
                                                        <td class="style4">
                                                            <asp:DropDownList ID="ddlRegYearMetro" runat="server">
                                                            </asp:DropDownList>
                                                            <asp:Button ID="btnMetro" runat="server" OnClick="btnMetro_Click" Text="Show Graph" />
                                                        </td>
                                                    </tr>
                                                </table>
                                            </td>
                                        </tr>
                                        <tr>
                                            <td>
                                                &nbsp;
                                                <table align="center" class="style1">
                                                    <asp:Panel ID="pnlMetro" runat="server">
                                                        <tr>
                                                            <td>
                                                                <chart:WebChartViewer ID="MetroRegistrationsGraph" runat="server" />
                                                            </td>
                                                        </tr>
                                                    </asp:Panel>
                                                </table>
                                            </td>
                                        </tr>
                                        <tr>
                                            <td>
                                                &nbsp;
                                            </td>
                                        </tr>
                                        <tr>
                                            <td>
                                                &nbsp;
                                            </td>
                                        </tr>
                                    </table>
                                </ContentTemplate>
                            </asp:UpdatePanel>
                        </td>
                        <td>
                            &nbsp;<table align="right" class="style1">
                                <tr>
                                    <td>
                                        <table align="center" class="style1">
                                            <tr>
                                                <td>
                                                    &nbsp;
                                                </td>
                                                <td>
                                                    &nbsp;
                                                </td>
                                            </tr>
                                        </table>
                                    </td>
                                </tr>
                                <tr>
                                    <td>
                                        <table align="center" class="style1">
                                            <tr>
                                                <td>
                                                    &nbsp;
                                                </td>
                                                <td>
                                                    &nbsp;
                                                </td>
                                            </tr>
                                        </table>
                                    </td>
                                </tr>
                                <tr>
                                    <td>
                                        &nbsp;
                                    </td>
                                </tr>
                                <tr>
                                    <td>
                                        &nbsp;
                                    </td>
                                </tr>
                                <tr>
                                    <td>
                                        &nbsp;
                                    </td>
                                </tr>
                            </table>
                            &nbsp;
                        </td>
                    </tr>
                </table>
            </td>
        </tr>
    </table>
</asp:Content>

Open in new window



I can give the code that shows how I'm getting & loading the data but I don't know how useful it would be to see that. So to summarize that code, for each graph:

in one routine I load data into some global list objects using an SQL statement
in another routine, I pull the data from the lists and put the data into arrays (the graphs require arrays to be used), that have also been declared globally and each graph uses its own set of lists and arrays
then I "activate" the graphs

The graphs don't load automatically when the page loads. The user has to make some selections from the drop downs and then click a button to kick off the processes to gather the data and then load the graphs with the data and show them.

In a effort to try to solve the problem, I wrapped my 2nd graph in an update panel and that seemed to help the problem in the sense that before i used the update panel, when ever I fired off a button to view a graph the two graphs would "toggle" (one would show, the other would disappear). I would get the same behavior if I wrapped both graphs in an update panel. At least as it stands now, the top graph always shows no matter what. but the 2nd graph disappears if the page refreshes or when ever i click the button to view data for the first graph. Any help / ideas would be appreciated.
0
Comment
Question by:mikesExpertExchange
  • 6
  • 6
12 Comments
 
LVL 12

Expert Comment

by:FarWest
Comment Utility
did you check the enable  viewstate property
0
 
LVL 1

Author Comment

by:mikesExpertExchange
Comment Utility
@fryezz: can you expand a little bit? I'm a little slow on the "uptake". "viewstate property" of what? the graph? the page?
0
 
LVL 12

Expert Comment

by:FarWest
Comment Utility
I think  viewstate in asp.net 4 has some  view state management changes
so you can try to make it enabled for both  graph and webpage to make sure

add this in chart tag

<asp:Chart ViewStateContent="SerializationContents" />
0
 
LVL 1

Author Comment

by:mikesExpertExchange
Comment Utility
@fryezz: I'll try to look into that further, right now the closest property to "ViewStateContent" that my chart control has is: "ViewStateMode" and none of the options for its possible values is: "SerializationContent". :-(
0
 
LVL 12

Expert Comment

by:FarWest
Comment Utility
try to put it directly in asp.net page not code behind

full reference is here

http://msdn.microsoft.com/en-us/library/system.web.ui.datavisualization.charting.chart.viewstatecontent(v=vs.100).aspx
0
 
LVL 1

Author Comment

by:mikesExpertExchange
Comment Utility
@fryezz: I think the reason that property isn't available, is because I'm not using the chart control provided by ASP .NET (Visual Studio), I'm using "ChartDirector" (by Advance Software Engineering: [ASE]).
0
Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

 
LVL 12

Expert Comment

by:FarWest
Comment Utility
:)
I saw the prefix in your code so I thought it is asp.net chart
please check similar attribute in your control,
if the control is OCX then there is a chance of a bug in coexisting 2 controls on the same page, because of some COM limitation or proper process isolation and you can check with them for bug fix
0
 
LVL 12

Expert Comment

by:FarWest
Comment Utility
btw
I think the workaround of using iframe for each control may work in case of ocx bug
0
 
LVL 1

Accepted Solution

by:
mikesExpertExchange earned 0 total points
Comment Utility
@fryezz: will do and thanks for your time and help. I'll see what I can find out. I think, in the mean time, just to keep my project moving, i'm going to have to reload each additional graph (all the graphs on the page) each time the page loads..:-(
0
 
LVL 1

Author Comment

by:mikesExpertExchange
Comment Utility
@fryezz: and ok about the iFrame solution, I'll have to research that, as I've never used an iFrame in any of my projects.
0
 
LVL 12

Expert Comment

by:FarWest
Comment Utility
I wish you a quick good luck (developers always need it :) )
0
 
LVL 1

Author Closing Comment

by:mikesExpertExchange
Comment Utility
Thank you.
0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Problem Hi all,    While many today have fast Internet connection, there are many still who do not, or are connecting through devices with a slower connect, so light web pages and fast load times are still popular.    If your ASP.NET page …
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…
This video explains how to create simple products associated to Magento configurable product and offers fast way of their generation with Store Manager for Magento tool.

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

6 Experts available now in Live!

Get 1:1 Help Now