我正在尝试访问下拉列表中的选定值,并在我的选择语句中传递该值,因此我只能提取过滤后的数据,但出现错误,并且由于此问题未生成图表。这是错误:“错误:'pieYScale' 为空或不是对象”。
我怀疑我在下拉列表中引用所选值的方式是错误的。
public string CreateChart()
{
string DDList = DropDownList1.SelectedValue;
SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["MyConnectionString"].ConnectionString);
string sqlStatement = "select Status as GroupCategory, Count(Status) as TotalCount from [MasterProject] where Closing_Date >= '" + txtStartClosingDate.Text + "' and Closing_Date <= '" + txtEndClosingDate.Text + "' and GroupProject = '" + DDList + "' and Status is not null group by Status Order by TotalCount Desc";
SqlCommand cmd = new SqlCommand(sqlStatement, con);
con.Open();
SqlDataReader reader = cmd.ExecuteReader();
string strXML;
strXML = "<graph decimalPrecision='0' name='MyXScaleAnim' type='ANIMATION' duration='1' start='0' param='_xscale' showNames='1' labelDisplay='Rotate' useEllipsesWhenOverflow='1' pieSliceDepth='30' formatNumberScale='0'>";
while (reader.Read())
{
strXML += "<set name='" + reader["GroupCategory"].ToString() + "' value='" + reader["TotalCount"].ToString() + "' />";
}
strXML += "</graph>";
return FusionCharts.RenderChart("../FusionCharts/Column3D.swf", "ChartID", strXML, "FactorySum", "500", "350", false, false);
}