zoukankan      html  css  js  c++  java
  • ASP.NET MVC3.0中同一View如何返回多个Model或数据集

    在控制器里定义一个Dictionary 泛型类,再把要用到的不同模型加进去

     controller:

        public ActionResult Index() {   


    IDictionary<string, object> test = new Dictionary<string, object>();
    test.Add("StudentList", new List<StudentInfo>());
    return View(test);
    }

     view视图:

    @model IDictionary<string, object> 
    @{Layout = null; }
    <!DOCTYPE html>
    <html>
    <head>
    <title>我的个人主页</title>
    </head>
    <body>
    <ul style="list-style: none; margin-left: 10px;">
    @foreach (var m in (IList<EnglishDiary.Models.StudentInfo>)Model["StudentList"]) {
    <li>@m.StuID</li>
    <li>@m.StuName</li>
    }
    </ul>
    </body>
    </html>
  • 相关阅读:
    POJ-2386 Lake Counting
    白书-部分和问题
    STL-map/multimap 简述
    STL-set&&multiset 集合
    STL-优先级队列-priority_queue
    挣脱虚无,化身虚无
    C
    B
    A
    STL-list 链表
  • 原文地址:https://www.cnblogs.com/512sz/p/3567590.html
Copyright © 2011-2022 走看看