我在条形图上收到错误:does not contain a definition for datasource
,另有错误barchart does not contain a definition for valuememberX and valuememberY
。
public void BindGrid()
{
// Load the name of the stored procedure where our data comes from here into commandtext
string CommandText = "enterprise.spCollectionAlerts";
// get the connection ready
SqlConnection myConnection = new SqlConnection(ConnectionString);
SqlCommand myCommand = new SqlCommand(CommandText, myConnection);
myCommand.CommandTimeout = ConfigSettings.SqlCommandTimeout;
SqlParameter workParam = new SqlParameter();
myCommand.CommandType = CommandType.StoredProcedure;
// Set the input parameter, companyid, branchid, departmentid
// these parameters are set in the sub page_load
myCommand.Parameters.Add("@CompanyID", SqlDbType.NVarChar).Value = CompanyID;
myCommand.Parameters.Add("@BranchID", SqlDbType.NVarChar).Value = BranchID;
myCommand.Parameters.Add("@DepartmentID", SqlDbType.NVarChar).Value = DepartmentID;
// open the connection
myConnection.Open();
SqlDataReader reader = myCommand.ExecuteReader(CommandBehavior.CloseConnection);
BarChart1.DataSource = reader;
BarChart1.Series[0].ValueMemberX = "ProductName";
BarChart1.Series[0].ValueMembersY = "TotalPurchase";
BarChart1.DataBind();