【发布时间】:2018-03-20 21:25:37
【问题描述】:
试图将部分视图转换为列表以及传递变量,但我似乎无法让它传递变量。在下方添加了一个 sn-p,感谢您的帮助。
这就是我想要做的(但使用部分视图,而不是 iframe。
<iframe src="/Episodes/Grid?seriesId=@Html.DisplayFor(model => model.SeriesID)"></iframe>
这就是我正在尝试的方法,但我无法让它同时转换为 List 并同时传递 SeriesID 变量。
@{
Html.RenderPartial("~/Views/Episodes/Grid.cshtml", new List<myA.Models.Episodes> { new myA.Models.Episodes() }; new { SeriesID = Model.SeriesID }););
}
根据 adiga 的建议,我创建了另一个模型,但出现内部服务器错误,见下文。
型号
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
namespace myA.Models
{
public class Combined
{
public IEnumerable<myA.Models.Episodes> Episodes { get; set; }
public string SeriesID { get; set; }
}
}
但我明白了
'IEnumerable<Episodes>' does not contain a definition for 'Number' and no extension method 'Number' accepting a first argument of type 'IEnumerable<Episodes>' could be found (are you missing a using directive or an assembly reference?)
【问题讨论】:
-
好的,我创建了一个新模型,名为 Combined with the episodes List 和 SeriesID。但是我收到很多“'IEnumerable
' 不包含'Number' 的定义,并且找不到接受'IEnumerable ' 类型的第一个参数的扩展方法'Number'(您是否缺少使用指令或程序集引用?)”错误? -
int,它为 db 表中的每一列发送垃圾邮件
标签: asp.net-mvc