2012-12-27 31 views
1

我有一個圖表,我必須將消息顯示爲「無數據存在」,此時rows.count == 0 否則通常爲條形圖。如何在asp圖表控件中顯示錯誤消息到圖表中

我可以知道如何顯示該消息。

在此先感謝。

+0

你有什麼迄今所做? –

+0

如果條件像這樣使用... –

+0

if(myTbl.Rows.Count == 0) { Chart1。??? =「此期間沒有數據」; } else { //我的圖表 –

回答

3

試試這個:

protected void ChartExample_DataBound(object sender, EventArgs e) 
{ 
    // If there is no data in the series, show a text annotation 
    if(ChartExample.Series[0].Points.Count == 0) 
    { 
     System.Web.UI.DataVisualization.Charting.TextAnnotation annotation = 
      new System.Web.UI.DataVisualization.Charting.TextAnnotation(); 
     annotation.Text = "No data for this period"; 
     annotation.X = 5; 
     annotation.Y = 5; 
     annotation.Font = new System.Drawing.Font("Arial", 12); 
     annotation.ForeColor = System.Drawing.Color.Red; 
     ChartExample.Annotations.Add(annotation); 
    } 
} 

感謝