日期:2014-05-16  浏览次数:20498 次

.NET MVC 返回model是List类型怎么绑定
.NET MVC 返回model是List类型如何绑定

public ActionResult UserList()
 
{

 List<Users> users = Fun.GetUsers(0);

            return View(users);
}

前台如何循环绑定返回的List<User> model.
------解决方案--------------------
页面上写一个List就行了啊。然后<%%>在里面写代码控制集合,可以循环。
------解决方案--------------------
Refer this:
http://www.cnblogs.com/insus/p/3372916.html

more related MVC:
http://www.cnblogs.com/insus/category/521762.html
------解决方案--------------------
在UserList()上点右键,创建视图,模型选择Users,模板选择List

或者手工创建一个视图,在开头加上
@model IEnumerable<Users>
------解决方案--------------------
foreach(var item in Model)
{
   //html
   数据绑定@item.字段
}

------解决方案--------------------
@model  List<Users>
当然引用List<>里面的Users需要把命名空间写全