本文介绍了我需要帮助来绑定Asp.Net数据图表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好,

我想从SQL数据表中绑定数据图表。下面是我正在使用的代码。

Hello,
I want to bind data chart from the SQL Data table. Below is the code that I am using.

private string QueryString = "SELECT [Qty], [Hour], [ObjectifTotal] FROM [TRGCharts]";
  SqlConnection conn = new SqlConnection(ConnectionString);
           SqlCommand cmd = new SqlCommand(QueryString, conn);

           SqlDataAdapter da = new SqlDataAdapter();
           da.SelectCommand = cmd;
           DataTable dt = new DataTable();
           da.Fill(dt);
           Chart1.DataSource = dt;
           Chart1.Series["Series1"].XValueMember = dt.Columns["Hour"].ToString();
           Chart1.Series["Series1"].YValueMembers = dt.Columns["Qty"].ToString();
           Chart1.Series["Series2"].XValueMember = dt.Columns["Hour"].ToString();
           Chart1.Series["Series2"].YValueMembers = dt.Columns["ObjectifTotal"].ToString();
           Chart1.DataSource = dt;
           this.Chart1.Series["Series1"].Points.AddXY(dt.Columns["Hour"].ToString(), dt.Columns["Qty"].ToString());
           this.Chart1.DataBind();
           this.Chart1.Series["Series2"].Points.AddXY(dt.Columns["Hour"].ToString(), dt.Columns["ObjectifTotal"].ToString());
           this.Chart1.DataBind();



我的问题是它总是绑定Series1.....如果我做错了请告诉我......

任何人帮我绑定多个系列的1个图表...


My problem is the it always bind the "Series1".....Please let me know if I was doing anything wrong...
Anybody help me to bind 1 Chart with multiple series...

推荐答案


这篇关于我需要帮助来绑定Asp.Net数据图表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-20 22:10