日期:2014-05-17 浏览次数:20522 次
public class HomeController : Controller
{
public ActionResult Index()
{
var list = new List<DataTable>()
{
new DataTable() { Id = 1, Num1 = 1, Num2 = 1 },
new DataTable() { Id = 2, Num1 = 2, Num2 = 2 }
};
return View(list);
}
}
public class DataTable
{
public int Id { get; set; }
public int Num1 { get; set; }
public int Num2 { get; set; }
}
@model List<MvcApplication1.Controllers.DataTable>
<table>
@{
foreach(var table in Model)
{
<tr><td>@table.Id<td><td>@table.Num1<td><td>@table.Num2<td><td>@(table.Num1 + table.Num2)<td></tr>
}
}
</table>