ASP.NET图表控件是空的

时间:2012-04-19 12:51:01

标签: c# asp.net charts

我想使用asp.net图表控件,在代码隐藏中使用此代码:

chIstatistik.DataSource =
                SqliteDatabase.ExecuteDataTable("SELECT COUNT(*) as sayi, kategoriNo FROM kisi WHERE kategoriNo = " +
                                                drpCategories.SelectedItem.Value);


            chIstatistik.Series["Series1"].XValueMember = "sayi";
            chIstatistik.Series["Series1"].YValueMembers = "kategoriNo";
            chIstatistik.DataBind();

我想要做的是,在给定的“kategoriNo”上显示行数。代码中有错误吗?图表显示为空,但我可以在数据源中看到数据。

由于

1 个答案:

答案 0 :(得分:0)

尝试以下代码

DataTable dt = SqliteDatabase.ExecuteDataTable("SELECT COUNT(*) as Yaxis, kategoriNo as Xaxis FROM kisi WHERE kategoriNo = " + drpCategories.SelectedItem.Value);
DataView dv = dt.DefaultView;
// Populate series data
chIstatistik.Series["Series1"].Points.DataBindXY(dv, "Xaxis", dv, "Yaxis");

KategoriNo应该是一些将在Xaxis上显示的名称。希望它有所帮助