2
我想從我的模型顯示屬性。目前我無法顯示頂部2人的地址?如何在asp.net mvc 3 razor中顯示modelproperty?
操作方法
public ActionResult Index()
{
Person person = new Person() {name="Jan Kees",address="Beukenootjes straat 23" };
Person person2 = new Person() { name = "Peter Jan", address = "Beukenootjes straat 23" };
List<Person> lijst = new List<Person>();
lijst.Add(person);
lijst.Add(person2);
return View(lijst);
}
人類
public class Person
{
public string name { get; set; }
public string address { get; set; }
}
索引視圖
@model IEnumerable<stack.Models.Person>
@item.address @*how to display address?*@
@foreach (var item in Model)
{
@item.name <br />
}
@ActiveDan:我想只顯示一次,因爲它是相同的地址。謝謝 – user603007