视图中 IEnumerable 的问题

发布于 2024-10-16 14:54:16 字数 1100 浏览 10 评论 0原文

我有一个枚举模型的视图。

在枚举模型的网格之外,我想要一个接受 MeetingActionId 参数的创建链接,它将 ActionUpdate 对象绑定到特定的 会议操作

如何获得创建链接来接受该属性?目前我收到错误

'System.Collections.Generic.IEnumerable' 不包含
 “MeetingActionId”的定义,并且没有扩展方法“MeetingActionId” 
 接受类型的第一个参数
可以找到“System.Collections.Generic.IEnumerable”

我认为这与 IEnumerable 有关。我本来打算通过将网格放入部分来解决这个问题,但这对我来说似乎是一个很糟糕的解决方案。

任何人都可以提供帮助,并希望教育我为什么会发生这种情况吗?

谢谢。

下面的代码片段使用 MVCContrib Grid 和 T4MVC 来实现强类型操作链接。

@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);
})

编辑:感谢大家的贡献。经过一番思考后,我决定最好将 actionupdates 网格呈现为 MeetingActions 的“详细信息”视图中的部分视图,从而完全避免此问题。

这个问题可以关闭

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

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

还如梦归 2024-10-23 14:54:16

你好
我不确定我是否正确理解了这一点,但模型似乎是一个包含 ActionUpdate 类型的项目的列表,该类型有一个名为 MeetingActionId 的属性。如果是这种情况,模型本身不具有您尝试使用的属性 MeetingActionId。也许你可以这样做:

Model.First().MeetingActionId

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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文