-4

我正在尝试访问下拉列表中的选定值,并在我的选择语句中传递该值,因此我只能提取过滤后的数据,但出现错误,并且由于此问题未生成图表。这是错误:“错误:'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);

    }
4

2 回答 2

0

我已经通过使用它来修复它:

 string DDList = DropDownList1.SelectedItem.Value;
于 2013-01-24T19:47:50.077 回答
0

撇开上面的代码对 SQL 注入攻击等完全开放,实际的错误本身来自 FusionCharts 组件,并且似乎是一个错误,需要更新来修复它。看这里

于 2013-01-24T19:04:26.653 回答