【发布时间】:2018-08-27 15:46:56
【问题描述】:
我想在一行中并排放置两列。这些列中的数据会有所不同。
像这样:
<div class="row">
<div class="col-md-6">
Data1
</div>
<div class="col-md-6">
Data2
</div>
</div>
但是..我的代码生成了一个结构:
<div class="row">
<div class="col-md-6 text-center">
</div>
<div class="col-md-6 text-center">
<h2>Title: </h2>
<p>Position: Name Surname</p>
</div>
<div class="row">
<div class="col-md-6 text-center">
<h2>Title: </h2>
<p>Position: Name Surname</p>
</div>
<div class="col-md-6 text-center">
</div>
</div>
这是我在 PartialView (_Pozycjee.cshtml) 中的代码:
@model IEnumerable<dynamic>
@if (Model.Any() == true)
{
foreach (dynamic item in Model)
{
@:<div class="row">
<div class="col-md-6 text-center">
@if (item.Mecz.GospodarzKlubId == item.Zawodnik.KlubId)
{
<h2>Skład gospodarzy:</h2>
<p>@item.Nazwa: @item.Zawodnik.Imie @item.Zawodnik.Nazwisko</p>
}
</div>
<div class="col-md-6 text-center">
@if (item.Mecz.GoscKlubId == item.Zawodnik.KlubId)
{
<h2>Skład gości:</h2>
<p>@item.Nazwa: @item.Zawodnik.Imie @item.Zawodnik.Nazwisko</p>
}
</div>
}
@: </div>
}
else
{
<p>Brak pozycji</p>
}
这会生成一个“空”的 div 并破坏一切。 看这个画面:https://photoland.io/i/k4Pzu
请寻求帮助。问候
【问题讨论】:
标签: asp.net-mvc foreach view