将视图列表从视图传递到控制器

时间:2016-03-08 18:46:17

标签: c# html asp.net-mvc

我想将视图中的集合(列表)传递给控制器​​。

查看Url.Action:

<div id="graph"><img src="@Url.Action("Draw", "Wishlist", new {list = Model.Products})" alt="Graph" /></div>

控制器 - 方法:

public ActionResult Draw(ICollection<Product> list )
        {
            int length = list.Count;
            string[] names = new string[length];
            int[] total = new int[length];
            DateTime week = DateTime.Now.StartOfWeek(DayOfWeek.Monday);
            for (int i=0; i <= lijst.Count; i++)
            {
                list.ForEach(p =>
                {
                    names[i] = p.Name;
                    total[i] = p.NumberPerWeek(week, week.AddDays(7));
                });
            }

            var c = new Chart(width: 250, height: 250)
                .AddSeries(
                    chartType: "bar",
                    yValues: new[] { "10", "20", "30", "40" },
                    xValue: new[] { "50", "60", "78", "80" }
                ).GetBytes("jpg");
            return File(c, "images/bytes");

但是当我运行我的项目时,列表为空。 建议?

0 个答案:

没有答案