相关疑难解决方法(0)

默认模型绑定器和包含列表的复杂类型

我正在使用ASP.NET MVC的RC1.

我正在尝试扩展Phil Haack的模型绑定示例.我正在尝试使用默认模型绑定器来绑定以下对象:

public class ListOfProducts
{
    public int Id { get; set; }
    public string Title{ get; set; }
    List<Product> Items { get; set; }
}

public class Product
{
    public string Name { get; set; }
    public decimal Price { get; set; }
}
Run Code Online (Sandbox Code Playgroud)

我正在使用Phil的示例中的代码进行一些更改:

控制器:

using System.Collections.Generic;
using System.Web.Mvc;

namespace TestBinding.Controllers
{
    [HandleError]
    public class HomeController : Controller
    {
        public ActionResult Index()
        {
            ViewData["Message"] = "Welcome to ASP.NET MVC!";

            return View();
        }

        //Action method …
Run Code Online (Sandbox Code Playgroud)

asp.net asp.net-mvc binding

5
推荐指数
1
解决办法
4698
查看次数

标签 统计

asp.net ×1

asp.net-mvc ×1

binding ×1