控制器:
public class HomeController : Controller
{
public ActionResult Index()//action
{
IUserInfoService uServ = MvcDemo.Models.ServiceBuilder.BuildUserSer();
IList<UserInfo> ui = uServ.GetAll();
return View(ui);
}
}
返回一个UserInfo的列表,单步到这都是对的,但是我在页面里不知道如何将它显示出来。
我的view: <table>
<tr>
<th>
</th>
<th>
ID
</th>
<th>
Name
</th>
<th>
sex
</th>
<th>
address
</th>
<th>
telphone
</th>
</tr>
这里是要填写的代码
</table>谢谢了
public class HomeController : Controller
{
public ActionResult Index()//action
{
IUserInfoService uServ = MvcDemo.Models.ServiceBuilder.BuildUserSer();
IList<UserInfo> ui = uServ.GetAll();
return View(ui);
}
}
返回一个UserInfo的列表,单步到这都是对的,但是我在页面里不知道如何将它显示出来。
我的view: <table>
<tr>
<th>
</th>
<th>
ID
</th>
<th>
Name
</th>
<th>
sex
</th>
<th>
address
</th>
<th>
telphone
</th>
</tr>
这里是要填写的代码
</table>谢谢了
<table>
<%foreach (UserInfo ui in Model)
{ %>
<tr><td><%:ui.ID%></td><td><%:ui.Name%></td><td><%:ui.sex%></td>……
<%}%>
</table>
所以问题会比较多。这MVC模式 完全颠覆了 以前的编程习惯啊
不是必须的 但是建议使用~ 可以用viewdata