我想訪問下拉列表中選定的值,並在我的選擇語句中傳遞該值,所以我只能拉過濾數據,但我越來越一個錯誤,並且圖表不是由於這個問題而產生的。這裏是錯誤:「錯誤:'pieYScale'爲空或不是對象」。
我懷疑我在下拉列表中引用選定值的方式是錯誤的。如何獲得在下拉列表中使用C#訪問選定的值#
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);
}
嘗試: DropDownList.Text – fabricio
嘗試把'DDList.ToSrting();或DDList.Text'我也建議改變你的查詢和使用參數化查詢 – MethodMan
什麼是pieYScale? –