Problem with IEnumerable in View

956 views Asked by At

I have a view that enumerates over a model.

Outside of the grid that enumerates over the model, I want to have a create link that accepts a parameter of MeetingActionId, that will bind the ActionUpdate object to a specific MeetingAction.

How do I get the create link to accept that property? at the moment i get the error

'System.Collections.Generic.IEnumerable' does not contain
 a definition for 'MeetingActionId' and no extension method 'MeetingActionId' 
 accepting a first argument of type
'System.Collections.Generic.IEnumerable' could be found 

I assume it's something to do with the IEnumerable. I was going to solve it by putting the grid in a partial, but that seems like a hacky solution to me.

Can anyone assist, and hopefully educate me as to why this is happening?

Thank you.

The code snippet below is using the MVCContrib Grid, and T4MVC for strongly typed action links.

@model IEnumerable<Actioner.Models.ActionUpdate>
@using MvcContrib.UI.Grid     

@{
    ViewBag.Title = "ListUpdates";
}

<h2>ListUpdates</h2>
@Html.ActionLink("Add New Update",MVC.ActionUpdates.Create(Model.MeetingActionId))


@Html.Grid(Model).Columns(column => {
   column.For(a=> a.UpdateText);
   column.For(a=> a.CreatedOn).Format("{0:d}");
   column.For(a=>a.CreatedBy);
})

EDIT: Thanks for the contributions guys. After some thinking i decided it would be better to have the grid of actionupdates rendered as a partial view within the 'details' view of the MeetingActions, thus avoiding this issue entirely.

This question could be closed

1

There are 1 answers

3
Pelle On

Hi I'm not sure that I understand this correctly but it seems like the Model is a list that contains items of type ActionUpdate, that type has a property called MeetingActionId. If that is the case the Model itself does not have the property MeetingActionId that you are trying to use. Perhaps you could to this:

Model.First().MeetingActionId