0

嗨,我是 mvc 和 bootstrap 的新手。我想在运行时在 mvc4 和 bootstrap 中动态添加两个文本框。我尝试了很多网站,但我无法理解。请给我一个简单的例子

我试过这个

在模型中

 public class Gift
    {
        public string Name { get; set; }
        public double Price { get; set; }
    }

在控制器中

public ActionResult PanelEx()
        {

            var initialData = new[] {
        new Gift { Name = "Tall Hat", Price = 39.95 },
        new Gift { Name = "Long Cloak", Price = 120.00 },
    };
            return View(initialData);

        }

我应该在模型中写什么。如何做下一步..我被卡住了请帮助

4

1 回答 1

0
public ActionResult PanelEx()
{
    var initialData = new List<Gift>{
    new Gift { Name = "Tall Hat", Price = 39.95 },
    new Gift { Name = "Long Cloak", Price = 120.00 },
};
    return View(initialData);
}

@model IEnumerable<Gift>

<div>
    @foreach(var item in Model)
    {
        <div>
        @Html.TextBoxFor(item=>item.Name)
        </div>
    }
</div>
于 2014-05-08T09:39:49.840 回答