I Got an Error Like This
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: CS1579: foreach statement cannot operate on variables of type 'EventListing.Models.EventInfo' because 'EventListing.Models.EventInfo' does not contain a public definition for 'GetEnumerator'
Source Error:
Line 106: </th>
Line 107: </tr>
Line 108: <% foreach (var model in Model)
Line 109: { %>
Line 110: <tr>
Model
public static List<EventInfo> EventList()
{
var list = new List<EventInfo>();
Dbhelper DbHelper = new Dbhelper();
DbCommand cmd = DbHelper.GetSqlStringCommond("SELECT * FROM WS_EVENTINFO");
DbDataReader Datareader = DbHelper.ExecuteReader(cmd);
while (Datareader.Read())
{
EventInfo eventinfo = new EventInfo()
{
EVENT_ID = Convert.ToInt32(Datareader[
View Page
<%@ Page Language="C#" Inherits="System.Web.Mvc.ViewPage<EventListing.Models.EventInfo>" %>
<% foreach (var model in Model)
{ %>
<tr>
<td>
<%= Html.ActionLink(Model.TITLE,"Detail", new {id = Model.EVENT_ID})%>
How can solve this Issue, i’m Using MVC2 Framework.
Presumably what you are trying to do is:
Although it is difficult to be sure.
If you require the syntax you used then Model will have to be an object of a class with a GetEnumerator() method.