控制器:
public ActionResult Index()
{
SonerSevincComEntities context = new SonerSevincComEntities();
var Konular = context.Konu.ToList();
return View(Konular);
}
看法:
<div class="primary">
@foreach (var item in Model)
{
<h2>
<a href="Subject?SubjectId=
@Html.DisplayFor(model => item.Id)">
@Html.DisplayFor(model => item.Baslik)</a>
</h2>
<p class="post-info">
<a href="Subject?Tag=
@Html.DisplayFor(model =>item.Etiket)">
@item.Etiket.Split(',').ToString()</a>
</p>
<div class="image-section">
<img src="@Html.DisplayFor(model => item.Resim)"
alt="image post" height="206" width="498" />
</div>
<p>
<a class="more" href="Subject?SubjectId==
@Html.DisplayFor(model => item.Id)">Devamı »</a>
</p>
}
</div>
我想在 (',') 下拆分
@item.Etiket.Split(',').ToString()
当我运行程序时,我看到了这段代码..
System.String[]代替 Etiket
我试图用 foreach Etiket.Split 解决这个问题,但 id 不起作用。
如何在 View 中解决这个问题?