Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/asp.net/34.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# Asp.Net中的AJAX折线图_C#_Asp.net_Ajax_Linechart - Fatal编程技术网

C# Asp.Net中的AJAX折线图

C# Asp.Net中的AJAX折线图,c#,asp.net,ajax,linechart,C#,Asp.net,Ajax,Linechart,我在asp.net中尝试设置AJAX折线图时遇到一些问题。我要做的是从下拉列表中选择一个类别,然后折线图将显示每个类别每月发送的产品总数。下面是表示层中的代码: protected void ddlCategory_SelectedIndexChanged(object sender, EventArgs e) { string categoryName = ddlCategory.SelectedItem.ToString(); string deliveryDate = ""

我在asp.net中尝试设置AJAX折线图时遇到一些问题。我要做的是从下拉列表中选择一个类别,然后折线图将显示每个类别每月发送的产品总数。下面是表示层中的代码:

protected void ddlCategory_SelectedIndexChanged(object sender, EventArgs e)
{
    string categoryName = ddlCategory.SelectedItem.ToString();
    string deliveryDate = "";
    decimal[] totalQuantity;

    List<ProductPacking> catSumList = new List<ProductPacking>();
    for (int count = 0; count < catSumList.Count; count++)
    {
        deliveryDate = catSumList[count].deliveryDate;
        totalQuantity = Convert.ToDecimal(catSumList[count].productQuantity);
    }
    lcCategory.Series.Add(new AjaxControlToolkit.LineChartSeries { Data = totalQuantity });
    lcCategory.CategoriesAxis = string.Join(",", deliveryDate);
    lcCategory.ChartTitle = string.Format("", deliveryDate);
    lcCategory.Visible = true;
}
线路。错误消息为无法将decimal类型隐式转换为decimal[]。我在这个网站上提到:

我想知道如何根据我的情况来解决这个问题。提前感谢。

在获得catSumList后移动totalQuantity声明,并将其更改为:

List<ProductPacking> catSumList = new List<ProductPacking>();
catSumList = BLL.getSumCategoryByMonth("Some Category");
decimal[] totalQuantity = new decimal[catSumList.Count];

谢谢它工作!!!但是您对如何从代码隐藏更改线条颜色有什么想法吗?很抱歉,我以前从未使用过AJAX线条图,但基于此:,控件具有BaseLineColor属性,也许就是这样?
public List<ProductPacking> getSumCategoryByMonth(string categoryName)
{
    List<ProductPacking> ft = new List<ProductPacking>();

    using (var connection = new SqlConnection(FoodBankDB.connectionString))
    {
        SqlCommand command = new SqlCommand("SELECT SUM(Convert(INT, ddi.productQuantity)) AS totalQuantity, pc.categoryName, d.deliveryDate FROM dbo.DistributionDistributedItems ddi " +
            " INNER JOIN dbo.ProductVariants pv ON ddi.productVariant = pv.id " +
            " INNER JOIN dbo.Products p ON pv.product = p.id " +
            " INNER JOIN dbo.ProductCategories pc ON p.productCategory = pc.id " +
            " INNER JOIN dbo.Distributions d ON ddi.distribution = d.id " +
            " WHERE categoryName = '" + categoryName + "'" + 
            " GROUP BY pc.categoryName, d.deliveryDate", connection);
        connection.Open();
        using (var dr = command.ExecuteReader())
        {
            while (dr.Read())
            {
                ft.Add(new ProductPacking(Convert.ToInt32(dr["totalQuantity"].ToString()), dr["deliveryDate"].ToString()));
            }
        }
    }
    return ft;
}
totalQuantity = Convert.ToDecimal(catSumList[count].productQuantity);
List<ProductPacking> catSumList = new List<ProductPacking>();
catSumList = BLL.getSumCategoryByMonth("Some Category");
decimal[] totalQuantity = new decimal[catSumList.Count];
for (int count = 0; count < catSumList.Count; count++)
{
    deliveryDate = catSumList[count].deliveryDate;
    totalQuantity[count] = Convert.ToDecimal(catSumList[count].productQuantity);
}