开发者

ASP.NET 4.0 Charting - How can one display a explanatory message in the chart area when the databound query returns no results?

I have a .Net 4 Chart Control bound to stored proc. For some customer selected queries the chart will be empty. I would like to display a "No data" message in the empty charting area so cust开发者_Go百科omers understand why the chart is empty. I haven't been able to find any information about how to do this.


I had the same problem. I resolved it by doing this in my code behind:

If MySQLReader.Read Then
            Chart1.DataSource = MySQLReader
            Chart1.Series("Series1").XValueMember = "XValue"
            Chart1.Series("Series1").YValueMembers = "YValue"
            Chart1.Height = 500
            Chart1.Width = 750
            Chart1.DataBind()
            LBLError.Text = ""
        Else
            Chart1.Visible = False
            LBLError.Text = "Your search did not match any records in the database"
            MySQLReader.Close()
            MyConn.Close()
        End If

Hope it helps.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜