MVC View - The result of a query cannot be enumerated more than once.
Hi,
I'm a newbie to MVC and am struggling to re-write a site that I previously wrote in webforms.
I have an existing stored procedure which when it gets called, populates a table with the weeks' football fixtures.
The user would then make their predictions for each fixture from drop downs and I then hope to insert all the predictions together using model binding.
I've shown the relevant code below from my view which is currently causing me a headache:
@model IEnumerable<PPLMVCNewOne.Models.sp_getMakeYourPred ictions_Result>
@for (int i = 0; i < Model.Count(); i++)
{
<tr>
<td>
@Html.DisplayFor(m => m.ElementAt(i).Home_Team)
What I'm trying to do is add an index so I can model bind within the action result.
It's at the html helper line that I'm getting the following error:
The result of a query cannot be enumerated more than once.
Can anyone please give me a pointer in the right direction?
Thanks in advance,
Dave
|