1
如何傳遞多個模型控制器和數據綁定到的ViewPage我得到一個錯誤「System.Collections.Generic.IEnumerable <EventListing.Models.MyViewModel>」不包含一個定義
我有列表頁在該頁面中包含兩個選項卡,一個用於活動列表,另一個用於活動列表。
如何創建模型並將數據綁定到查看頁面。
我如何將數據綁定到瀏覽網頁,我使用強類型模型
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()
};
這是我的看法頁面代碼
<% 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>
感謝man.it工程更改您的ViewPage。 – Sathish