Why does my graph lose its data?

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.
LVL 1
Michael SterlingWeb Applications DeveloperAsked:
Who is Participating?
 
Michael SterlingConnect With a Mentor Web Applications DeveloperAuthor Commented:
@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
 
FarWestCommented:
did you check the enable  viewstate property
0
 
Michael SterlingWeb Applications DeveloperAuthor Commented:
@fryezz: can you expand a little bit? I'm a little slow on the "uptake". "viewstate property" of what? the graph? the page?
0
The new generation of project management tools

With monday.com’s project management tool, you can see what everyone on your team is working in a single glance. Its intuitive dashboards are customizable, so you can create systems that work for you.

 
FarWestCommented:
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
 
Michael SterlingWeb Applications DeveloperAuthor Commented:
@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
 
FarWestCommented:
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
 
Michael SterlingWeb Applications DeveloperAuthor Commented:
@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
 
FarWestCommented:
:)
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
 
FarWestCommented:
btw
I think the workaround of using iframe for each control may work in case of ocx bug
0
 
Michael SterlingWeb Applications DeveloperAuthor Commented:
@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
 
FarWestCommented:
I wish you a quick good luck (developers always need it :) )
0
 
Michael SterlingWeb Applications DeveloperAuthor Commented:
Thank you.
0
All Courses

From novice to tech pro — start learning today.