Can't bind datatable to Chart Control

后端 未结 3 489
萌比男神i
萌比男神i 2021-01-21 02:24

I\'d like to use a polar chart in my test application. I\'ve a data table with a couple of columns where the column with the name of \"X\" should provide the x value members, th

相关标签:
3条回答
  • 2021-01-21 03:07

    This may help you Write this on page load

    chart.DataSource = dataqtableName;
    chart.Series["seriesName"].XValueMember = "columNameUwantToBind";
    chart.Series["seriesName"].YValueMembers = "columNameUwantToBind";
    chart.DataBind();
    
    0 讨论(0)
  • 2021-01-21 03:16

    It won't compile because DataTable doesn't implement IEnumerable interface. Try:

    var enumerableTable = (dt as System.ComponentModel.IListSource).GetList();
    chart1.DataBindTable(enumerableTable , "X");
    
    0 讨论(0)
  • 2021-01-21 03:17

    Another solution might be:

    chart1.DataBindTable(dt.DefaultView, "X");
    

    As a bonus, the DataView this returns can be used for sorting and filtering, besides being "databindable".

    0 讨论(0)
提交回复
热议问题