Razor声明并使用变量语法

时间:2018-01-20 00:07:46

标签: asp.net-mvc razor

我正在尝试使用此剃须刀模板,但无法正确声明FDate1,2,3,4,5,etc...的变量。

例如,我刚刚将第一个FDate1包含在顶部。我的代码的下半部分正确地处理了循环部分。

我做错了什么?

@{
string FDate1 = var row in AME.GridF18.FDate1("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>
        <th colspan="1" scope="col">@FDate8</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">&nbsp;</th>
      <th scope="col">&nbsp;</th>
      <th scope="col">&nbsp;</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 个答案:

没有答案