【问题标题】:How can I bind an asp:chart (from microsoft) to a Dictionary<string,string>?如何将 asp:chart(来自 microsoft)绑定到 Dictionary<string,string>?
【发布时间】:2010-08-02 22:24:02
【问题描述】:

我正在为 ASP.Net 使用 MS 图表控件,但我无法确定绑定。 有人知道如何将 asp:chart(来自微软)绑定到字典吗?

【问题讨论】:

  • 你试过将Key和Value这两个词绑定成字段吗?

标签: c# asp.net charts datasource


【解决方案1】:
var employees = new Dictionary<int, string>
{
    {10,"Employee 1"},{20,"Employee 2"},{30,"Employee 3"}
};

Chart1.Series[0].ChartType = System.Web.UI.DataVisualization.Charting.SeriesChartType.Bar;

foreach (KeyValuePair<int, string> employee in employees)
    Chart1.Series[0].Points.AddXY(employee.Value, employee.Key);

输出:

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-08-04
    • 1970-01-01
    • 1970-01-01
    • 2013-02-27
    • 1970-01-01
    • 2011-06-15
    相关资源
    最近更新 更多