john kanyora

john kanyora

  • NA
  • 242
  • 46.5k

barchart does not contain a definiton for datasource.

Dec 7 2017 7:26 AM
am getting the error of barchart does not contain a definition for datasource and another error of barchart does not contain a definition for valuememberX and valuememberY.
i have highlighted in red where am getting the error.
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();

<html>
<head>
</head>
<body >
<asp:BarChart ID="BarChart1" runat="server" ChartHeight="300" ChartWidth = "450"
ChartType="Column" ChartTitleColor="#0E426C" Visible = "false"
CategoryAxisLineColor="#D08AD9" ValueAxisLineColor="#D08AD9" BaseLineColor="#A156AB">
</asp:BarChart>
</body>
</html>

Answers (5)