I have a chart and an updatepanel.
I load the chart data first time the form loads.
When I press the button, I expect the chart data to stay the same, since it is not on the updatepanel.
I only want the updatepanel to refresh.
But the chart give the warning: Data not available ...
using System;using System.Collections.Generic;using System.Linq;using System.Web;using System.Web.UI;using System.Web.UI.WebControls;using Infragistics.UltraChart.Shared.Styles;using System.Data;
namespace WebApplication11{ public partial class WebForm2 : System.Web.UI.Page {
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { UltraChart1.ChartType = ChartType.ColumnChart; DataTable columnData = new DataTable("ColumnData"); columnData.Columns.Add("Month", typeof(string)); columnData.Columns.Add("Foo", typeof(double)); columnData.Columns.Add("Bar", typeof(double)); //Add additional columns here; for each column add a parameter to each row below. //Below uses params so additional columns of data are comma delimited columnData.Rows.Add("Jan"/*Month*/, 3400/*Foo*/, 1200/*Bar*/ /*, YourNewColumn*/); columnData.Rows.Add("Feb", 2300, 1200); columnData.Rows.Add("Mar", 5994, 1200); UltraChart1.DataSource = columnData; UltraChart1.DataBind(); Label1.Text = "xx"; } }
protected void Button1_Click(object sender, EventArgs e) {
}
}}
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="WebForm2.aspx.cs" Inherits="WebApplication11.WebForm2" %>
<%@ Register Assembly="Infragistics4.WebUI.UltraWebChart.v12.2, Version=12.2.20122.2054, Culture=neutral, PublicKeyToken=7dd5c3163f2cd0cb" Namespace="Infragistics.WebUI.UltraWebChart" TagPrefix="igchart" %><%@ Register assembly="Infragistics4.WebUI.UltraWebChart.v12.2, Version=12.2.20122.2054, Culture=neutral, PublicKeyToken=7dd5c3163f2cd0cb" namespace="Infragistics.UltraChart.Resources.Appearance" tagprefix="igchartprop" %><%@ Register assembly="Infragistics4.WebUI.UltraWebChart.v12.2, Version=12.2.20122.2054, Culture=neutral, PublicKeyToken=7dd5c3163f2cd0cb" namespace="Infragistics.UltraChart.Data" tagprefix="igchartdata" %><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head runat="server"> <title></title></head><body> <form id="form1" runat="server"> <asp:ScriptManager ID="ScriptManager1" runat="server"> </asp:ScriptManager> <asp:UpdatePanel ID="UpdatePanel1" runat="server"> <ContentTemplate> <igchart:UltraChart ID="UltraChart1" runat="server" EmptyChartText="Data Not Available. Please call UltraChart.Data.DataBind() after setting valid Data.DataSource" Version="12.2"> </igchart:UltraChart> <asp:Label ID="Label1" runat="server" Text="Label"></asp:Label> </ContentTemplate> <Triggers> </Triggers> </asp:UpdatePanel> <asp:Button ID="Button1" runat="server" Text="Button" onclick="Button1_Click" /> <asp:UpdatePanel ID="UpdatePanel2" runat="server"> <ContentTemplate> </ContentTemplate> <Triggers> <asp:AsyncPostBackTrigger ControlID="Button1" EventName="Click" /> </Triggers> </asp:UpdatePanel> <div> </div> </form></body></html>
Hello drpoalim,
Our WebChart requires rebinding on every postback, so I could suggest you modify your Page_Load method like this:
protected void Page_Load(object sender, EventArgs e) { UltraChart1.ChartType = ChartType.ColumnChart; DataTable columnData = new DataTable("ColumnData"); columnData.Columns.Add("Month", typeof(string)); columnData.Columns.Add("Foo", typeof(double)); columnData.Columns.Add("Bar", typeof(double)); //Add additional columns here; for each column add a parameter to each row below. //Below uses params so additional columns of data are comma delimited columnData.Rows.Add("Jan"/*Month*/, 3400/*Foo*/, 1200/*Bar*/ /*, YourNewColumn*/); columnData.Rows.Add("Feb", 2300, 1200); columnData.Rows.Add("Mar", 5994, 1200); UltraChart1.DataSource = columnData; UltraChart1.DataBind(); Label1.Text = "xx"; }
Please let me know if this helps.