动态创建Asp Chart多系列

时间:2010-03-18 03:51:45

标签: asp.net charts

如何动态创建多系列ASP.net图表。

1 个答案:

答案 0 :(得分:0)

private void BindChart(DataTable dt)
{
    dt.DefaultView.Sort = "Category Asc";

    DataTable dtSorted = dt.DefaultView.ToTable();

    string sCategoryName = string.Empty;
    string sOldCategoryName = string.Empty;
    for (int i = 0; i < dtSorted.Rows.Count; i++)
    {
        sCategoryName = dtSorted.Rows[i]["Category"].ToString();
        if (sCategoryName != sOldCategoryName)
        {
            // Your logic here to bind the category in chart
            sOldCategoryName = sCategoryName;
        }
        // Bind other details (description etc) from the table.
    }
}