我的剃刀模板出现错误,说:编译Razor模板时出错:无法调用非委托类型(查看日志以获取更多详细信息)
我尝试用@和no @声明变量,两个方法都给出了同样的错误。
底部的循环部分工作正常,只是顶部的单个非循环日期我遇到了麻烦。
@{
var FDate1 = @AME.GridF18.FDate1("SubmissionID='" + TknParams.SubmissionID + "'");
var FDate2 = @AME.GridF18.FDate2("SubmissionID='" + TknParams.SubmissionID + "'");
var FDate3 = @AME.GridF18.FDate3("SubmissionID='" + TknParams.SubmissionID + "'");
var FDate4 = @AME.GridF18.FDate4("SubmissionID='" + TknParams.SubmissionID + "'");
var FDate5 = @AME.GridF18.FDate5("SubmissionID='" + TknParams.SubmissionID + "'");
var FDate6 = @AME.GridF18.FDate6("SubmissionID='" + TknParams.SubmissionID + "'");
var FDate7 = @AME.GridF18.FDate7("SubmissionID='" + TknParams.SubmissionID + "'");
}
<div class="table-responsive">
<table class="table table-striped table-condensed table-bordered" width="100%" border="0">
<tbody>
<tr>
<th colspan="7" scope="col">@FDate1</th>
<th colspan="2" scope="col">@FDate2</th>
<th colspan="2" scope="col">@FDate3</th>
<th colspan="2" scope="col">@FDate4</th>
<th colspan="2" scope="col">@FDate5</th>
<th colspan="2" scope="col">@FDate6</th>
<th colspan="1" scope="col">@FDate7</th>
</tr>
<tr>
<th rowspan="2" scope="col">Project #</th>
<th rowspan="2" scope="col">PW</th>
<th rowspan="2" scope="col">Project Name</th>
<th rowspan="2" scope="col">Type of Work</th>
<th rowspan="2" scope="col">Mile</th>
<th rowspan="2" scope="col">Toll</th>
<th rowspan="2" scope="col">Park</th>
<th colspan="2" scope="col">Monday</th>
<th colspan="2" scope="col">Tuesday</th>
<th colspan="2" scope="col">Wednesday</th>
<th colspan="2" scope="col">Thursday</th>
<th colspan="2" scope="col">Friday</th>
<th scope="col">Saturday</th>
<th scope="col">Sunday</th>
<th scope="col">Total</th>
</tr>
<tr>
<th scope="col">RT</th>
<th scope="col">OT</th>
<th scope="col">RT</th>
<th scope="col">OT</th>
<th scope="col">RT</th>
<th scope="col">OT</th>
<th scope="col">RT</th>
<th scope="col">OT</th>
<th scope="col">RT</th>
<th scope="col">OT</th>
<th scope="col"> </th>
<th scope="col"> </th>
<th scope="col"> </th>
</tr>
@foreach (var row in AME.GridF18("SubmissionID='" + TknParams.SubmissionID + "'")) {
<tr>
<td>@row.ProjectNumber</td>
<td><input id="checkBox" type="checkbox"></td>
<td>@row.ProjectName</td>
<td>@row.TypeofWork</td>
<td>@row.Mile</td>
<td>@row.Toll</td>
<td>@row.Park</td>
<td>@row.MonRT</td>
<td>@row.MonOT</td>
<td>@row.TuesRT</td>
<td>@row.TuesOT</td>
<td>@row.WedsRT</td>
<td>@row.WedsOT</td>
<td>@row.ThursRT</td>
<td>@row.ThursOT</td>
<td>@row.FriRT</td>
<td>@row.FriOT</td>
<td>@row.Saturday</td>
<td>@row.Sunday</td>
<td>@row.Total</td>
</tr>
}
</tbody>
</table>
</div>
答案 0 :(得分:1)
编译Razor模板时出错:无法调用非委托类型。 因为这句话
@foreach (var row in AME.GridF18("SubmissionID='" + TknParams.SubmissionID + "'")) {
这里GridF18被编译器视为委托,它期望返回ienumberable。
看起来您正在尝试遍历日期列表。您需要创建一个列表,然后将这些日期添加到列表中,并在循环中将该列表用作集合源