控制器:
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>谢谢了

解决方案 »

  1.   

    用for或foreach遍历呗,不懂再看几遍教程
      

  2.   

    在index那里点击右键,添加视图,选择强类型,下拉框里找到UserInfo的实体类,下面还有个下拉框,选择List,生成一个View,看看是怎么显示的就知道了
      

  3.   

    首先,view中使用强类型下面:
    <table>
    <%foreach (UserInfo ui in Model)
      { %>
    <tr><td><%:ui.ID%></td><td><%:ui.Name%></td><td><%:ui.sex%></td>……
    <%}%>
    </table>
      

  4.   

    必须在建VIEW的时候使用强类型吗?
      

  5.   

    我是临时学的 因为有个急项目  来不及系统看书, 只能看基本的
    所以问题会比较多。这MVC模式 完全颠覆了 以前的编程习惯啊
      

  6.   


    不是必须的 但是建议使用~  可以用viewdata