0
        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

1
Contributor
1
Reply
6
Views
3 Years
Discussion Span
Last Post by gahhon
0

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.
This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.