0

I has using dexexpress chartcontrol and bind the datasource in runtime.

chartControl1.DataSource = ds.Tables[0];
chartControl1.SeriesDataMember = "Task";
chartControl1.SeriesTemplate.ArgumentDataMember = "Resource";
chartControl1.SeriesTemplate.ValueDataMembers.AddRange(new string[] { "Percentage" });
chartControl1.SeriesTemplate.View = new StackedBarSeriesView();

The first time binding, it has work fine and can show the chart. When I click a button to re-create the dataset with new row of data, it give me an error in chartControl1.DataSource = ds.Tables[0];

I has set the dataset = new dataset before fill it again with new data.

Any one has idea what wrong. Please help.

Bubble Bub
  • 651
  • 4
  • 12
  • 32
  • You should not have to reset the datasource, just adjust the existing datasource. – Bit May 15 '14 at 18:42

2 Answers2

0

You should be able to do something along the lines of the following:

        this.chartControl1.BeginInit();
        DataTable chartData = this.chartControl1.DataSource as DataTable;


        DataRow row = new DataRow()
        {
            "col1",
            "col2"
        }

        chartData.Rows.Add(row);
        this.chartControl1.RefreshData();
        this.chartControl1.EndInit();

I hope this is helpful.

Bit
  • 1,068
  • 1
  • 11
  • 20
-1

I have found that DevExpress occasionally gets confused when I set the DataSource, especially to an existing object. To work round this, before I set the DataSource to anything, I always set it to null first. Since doing that, I have not had any problems.

Give that a try.

sab
  • 721
  • 6
  • 7
  • Hi Sab, I has try set the datasource to null before re-bind but it also the same. Do you has any idea? – Bubble Bub May 16 '14 at 00:31
  • Not sure I want to reply, given that I was down voted for a suggestion! Still, when are you setting the data source to null? Make sure you null it before you re-build the dataset. The error results from the control accessing the datasource while the dataset is being rebuilt. – sab May 16 '14 at 14:07