protected void Page_Load(object sender, EventArgs e)
        {
            double totalUsage = 0;
            int rowCount = getRowCount();
            int columnCount = getColumnCount();
            string[] xValues = getColumnName();
            double[] yValues = new double[columnCount];
            SqlConnection conBudget = new SqlConnection(ConfigurationManager.ConnectionStrings["connMSJ"].ConnectionString);
            SqlCommand cmdBudget = new SqlCommand("SELECT Foods, Clothes, Drinks, Entertaiment FROM DailyBudget WHERE (Username=@username)", conBudget);            
            conBudget.Open();
            cmdBudget.Parameters.AddWithValue("@username", "gahhon");
            SqlDataReader dtrBudget = cmdBudget.ExecuteReader();
            if (dtrBudget.Read())
                for (int i = 0; i < columnCount; i++)
                {
                    yValues[i] = Convert.ToDouble(dtrBudget[i]);
                    totalUsage += Convert.ToDouble(dtrBudget[i]);
                }
            dtrBudget.Close();
            conBudget.Close();
            double RemainBudget = getRemainBudget(totalUsage);
            lblBudget.Text = "RM " + getDailyBudget().ToString("n2");
            lblCurrent.Text = "RM " + getCurrentBudget().ToString("n2");
            lblRemaining.Text = "RM " + RemainBudget.ToString("n2");
            insertChart(xValues, yValues);
        }
        protected void insertChart(string[] xValues, double[] yValues)
        {
            pcBudget.Series["Series1"]["PieLabelStyle"] = "Outside";
            pcBudget.Series["Series1"].Points.DataBindXY(xValues, yValues);
            pcBudget.Series["Series1"].EmptyPointStyle.IsValueShownAsLabel = false;
            pcBudget.Series["Series1"].EmptyPointStyle.IsVisibleInLegend = false;
            pcBudget.Series["Series1"].LegendText = "#VALX #PERCENT{P2}";
            pcBudget.DataManipulator.Sort(PointSortOrder.Descending, pcBudget.Series["Series1"])

DataBindXY(xValues, yValues) Occured the problem of Enumeration already finish. thanks for in advance

Problem solved because xValues and yValues having different array size. Thus problem occurs.
To Solved This problem

  1. Make Sure both array having the same array size.
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.