john kanyora

john kanyora

  • NA
  • 242
  • 46.6k

Input string was not in a correct format.

Dec 20 2017 3:54 AM
Hi, am converting string to decimal because i want my values to be represented in decimal form in my bar chart.am getting the error that " Input string was not in a correct format"..
 
the error is in this line y[i]=Convert.ToDecimal(string.Format("{0}.00",dt.Rows[i][1].ToString()));
am usin this code below
 
string[] x = new string[dt.Rows.Count];
decimal[] y = new decimal[dt.Rows.Count];
for (int i = 0; i < dt.Rows.Count; i++)
{
x[i] = dt.Rows[i][0].ToString();
y[i]=Convert.ToDecimal(string.Format("{0}.00",dt.Rows[i][1].ToString()));
}
BarChart1.Series.Add(new AjaxControlToolkit.BarChartSeries {Data=y });
BarChart1.CategoriesAxis = string.Join(",", x);
BarChart1.ChartWidth = 500.ToString();
BarChart1.ChartHeight = 600.ToString();
}
 
kindly help

Answers (16)