Solved

Why does my graph lose its data?

Posted on 2014-11-24
12
173 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
ID: 40463987
did you check the enable  viewstate property
0
 
LVL 1

Author Comment

by:mikesExpertExchange
ID: 40464632
@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
ID: 40464758
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
Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

 
LVL 1

Author Comment

by:mikesExpertExchange
ID: 40464786
@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
ID: 40464796
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
ID: 40464815
@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
 
LVL 12

Expert Comment

by:FarWest
ID: 40464829
:)
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
ID: 40464837
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
ID: 40464838
@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
ID: 40464840
@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
ID: 40464861
I wish you a quick good luck (developers always need it :) )
0
 
LVL 1

Author Closing Comment

by:mikesExpertExchange
ID: 40569024
Thank you.
0

Featured Post

3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…

777 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