Asp.net mvc 2 我出错了';System.Collections.Generic.IEnumerable<;EventListing.Models.MyViewModel>';不包含定义

Asp.net mvc 2 我出错了';System.Collections.Generic.IEnumerable<;EventListing.Models.MyViewModel>';不包含定义,asp.net-mvc-2,Asp.net Mvc 2,如何将多个模型传递给控制器并将数据绑定到viewpage 我有一个列表页面,该页面包含两个选项卡,一个用于活动列表,另一个用于活动列表 如何创建模型并将数据绑定到viewpage 如何将数据绑定到视图页面,我使用了强类型模型 public class EventInfo { public string SUBSITE { get; set; } public string TITLE { get; set; } ------ } public cla

如何将多个模型传递给控制器并将数据绑定到viewpage

我有一个列表页面,该页面包含两个选项卡,一个用于活动列表,另一个用于活动列表

如何创建模型并将数据绑定到viewpage

如何将数据绑定到视图页面,我使用了强类型模型

public class EventInfo  
    {

        public string SUBSITE { get; set; }
        public string TITLE { get; set; }
------
}
public class MyViewModel
{
    public IEnumerable<SomeViewModel> Active { get; set; }
    public IEnumerable<SomeViewModel> InActive { get; set; }
}



var model = new MyViewModel
            {
                Active = EventModel.EventList(ids, "", "", "", "", "", "", "", "1", "").ToList(),
                InActive = EventModel.EventList(ids, "", "", "", "", "", "", "", "1", "1").ToList()
            };
公共类事件信息
{
公共字符串子网站{get;set;}
公共字符串标题{get;set;}
------
}
公共类MyViewModel
{
公共IEnumerable活动{get;set;}
公共IEnumerable非活动{get;set;}
}
var模型=新的MyViewModel
{
Active=EventModel.EventList(ID、、、、、、、、、、、、、、、、、、、、、).ToList(),
InActive=EventModel.EventList(ID,“,”,“,”,“,”,“,”,“,”,“,”,“1”,“1”).ToList()
};
这是我的查看页面代码

<% foreach (var model in Model)
   { %>
     <tr>
       <td>
          <%= Html.ActionLink(model.TITLE, "Detail", new { id = model.EVENT_ID })%>
        </td>

我犯了个错误

Description: An error occurred during the compilation of a resource required to service this request. Please review the following specific error details and modify your source code appropriately. 

Compiler Error Message: CS1061: 'System.Collections.Generic.IEnumerable<EventListing.Models.MyViewModel>' does not contain a definition for 'Active' and no extension method 'Active' accepting a first argument of type 'System.Collections.Generic.IEnumerable<EventListing.Models.MyViewModel>' could be found (are you missing a using directive or an assembly reference?)

Source Error:



Line 221:                    </thead>
Line 222:                    <tbody>
Line 223:                        <% foreach (var model in Model.Active)
Line 224:                           { %>
Line 225:                        <tr>
Description:编译服务此请求所需的资源时出错。请查看以下特定错误详细信息,并适当修改源代码。
编译器错误消息:CS1061:“System.Collections.Generic.IEnumerable”不包含“Active”的定义,并且找不到接受“System.Collections.Generic.IEnumerable”类型的第一个参数的扩展方法“Active”(是否缺少using指令或程序集引用?)
源错误:
第221行:
第222行:
第223行:
第225行:

您的查看页面代码与您发布的错误消息不匹配

ViewPage代码显示您传递的模型是一组
MyViewModel
的集合,您通过这些集合循环显示链接

错误消息表示您只传递了一个
MyViewModel
,并且希望在
Active
集合中循环

更改您的查看页面,以便使用

@model MyViewModel
而不是

@model IEnumerable<MyVieWModel>
@model IEnumerable