Jump to content
Software FX Community



Recommended Posts

Im going bonkers... im trying to create a simple datatable and attach it to  a chart as a datasource.But when i run the program, the compiler throws a system.formatexception and shows the message "Input string was not in a correct format".

I have visual studio 2005 and .net 2.0, i have managed to get other datasets (which were poulated by queries to database) connected to the chart and get them to run properly, but only when i MANUALLY try to populate a datable with data and then connect to the chart, do i get this error..... this must be a big silly one...but i cant get it right now...

heres the code

//Create Data Table at runtimeDataTable dtTemp = new DataTable();dtTemp.Columns.Add("Dates");dtTemp.Columns.Add("Percentages");

//Add one rowDataRow dr1 = dtTemp.NewRow();DateTime dt1 = new DateTime(2007, 02, 01);dr1["Dates"] = dt1.Date ;dr1["Percentages"] = 50;dtTemp.Rows.Add(dr1);dtTemp.AcceptChanges();

//Add another rowDataRow dr2 = dtTemp.NewRow();DateTime dt2 = new DateTime(2007, 02, 02);dr2["Dates"] = dt2.Date ;dr2["Percentages"] = 100;dtTemp.Rows.Add(dr2);dtTemp.AcceptChanges();

Chart1.DataSourceSettings.Fields.Add(new FieldMap("Dates",FieldUsage.XValue));Chart1.DataSourceSettings.Fields.Add(new FieldMap("Percentages", FieldUsage.Value));Chart1.DataSource = ds1 ;


Link to comment
Share on other sites

When binding against datatable or datasources, we query the datatable for information about the type of the columns instead of discovering it from the data (we do try to discover when reading data from text files).

This means you have to change the way you create the datatable columns as follows





Link to comment
Share on other sites


This topic is now archived and is closed to further replies.

  • Create New...