我正在使用 CodePlex 免费的 Libero.FusionCharts 库作为更好的 Yahoo.FusionCharts。根据文档,我添加了一个 FChart 控件作为图表的占位符。
<%@ Register Assembly="Libero.FusionCharts" Namespace="Libero.FusionCharts.Control" TagPrefix="fcl" %>
<fcl:FChart runat="server" ID="chtProductSales" Width="530" Height="300" />
然后我在页面加载中执行以下操作:
MSColumn3DLineDYChart oChart = new MSColumn3DLineDYChart();
// Set properties
oChart.Background.BgColor = "ffffff";
oChart.Background.BgAlpha = 50;
oChart.ChartTitles.Caption = "Response Time";
// Set a template
oChart.Template = new Libero.FusionCharts.Template.OfficeLightTemplate();
ObjectDataSource ods = new ObjectDataSource();
ods.SelectMethod = "GetCenterETAPTA";
ods.TypeName = "reportingDB";
DataView dv = (DataView)ods.Select();
dv.Sort = "ChartSort ASC";
DataTable dt = dv.ToTable();
oChart.DataSource = dt;
oChart.DataCategoryTextField = "HOC";
oChart.DataSeriesTextField = "NOC";
oChart.DataSeriesValueField = "Club";
// Link the WebControl and the Chart
// FChart chart = (FChart) Page.FindControl(this.chtProductSales.ClientID);
chtProductSales.ShowChart(oChart);
// chart.ShowChart(oChart);
在 chtProductSales 线上,它应该与 webcontrol 连接。编译器说:
错误 1 当前上下文中不存在名称“chtProductSales”
但是,我可以做 Intellisense 并获得 this.chtProductSales!编译器有什么问题?我尝试了一个具有相同结果的 FindControl 调用。文档说明了我所需要的一切:
// Link the WebControl and the Chart
chtProductSalles.ShowChart(oChart);
他们发货的示例有效。到底是怎么回事?