다음 코드를 사용하여 테이블 머리글을 @foreach 외부에 놓고 싶습니다.하지만 외부로 이동하면 더 이상 닫는 태그가 표시되지 않습니다. 감사합니다면도기 구문 오류가 잘못되었습니다.
@foreach (var item in Model)
{
<div class="data" ><label for="fullName" >Name: </label>@item.UserName.Replace('.', '')</div>
if (Model.Count > 0)
{
<table class="data">
<tr>
<th>
Work Date
</th>
<th>
Change Details
</th>
<th>
Ip Address
</th>
<th></th>
</tr>
<tr>
<td>
@{
var stringDate = item.WorkDate.ToShortDateString();
}
@Html.DisplayFor(modelItem => stringDate)
</td>
<td>
@Html.DisplayFor(modelItem => item.ChangeDetail)
</td>
<td>
@Html.DisplayFor(modelItem => item.IpAddress)
</td>
</tr>
</table>
}
<br />
<hr />
}
그래서 이것은 내가 달성하기 위해 노력하고있어 좀이지만, 아무리 내가하려고 어떤 방법으로 나에게 오류를 제공하지 유지합니다.
<table class="data">
<tr>
<th>
Work Date
</th>
<th>
Change Details
</th>
<th>
Ip Address
</th>
<th></th>
</tr>
@foreach (var item in Model)
{
<div class="data" ><label for="fullName" >Name: </label>@item.UserName.Replace('.','')</div>
if (Model.Count > 0)
{
<tr>
<td>
@{
var stringDate = item.WorkDate.ToShortDateString();
}
@Html.DisplayFor(modelItem => stringDate)
</td>
<td>
@Html.DisplayFor(modelItem => item.ChangeDetail)
</td>
<td>
@Html.DisplayFor(modelItem => item.IpAddress)
</td>
</tr>
</table>
}
<br />
<hr />
}
와우 나는 무지하게 20 분 동안 그것을 어지럽히고 있다고 느낀다. 감사) – Jesse